<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:51:41 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-185] add OutputStream capability to GridFSInputFile</title>
                <link>https://jira.mongodb.org/browse/JAVA-185</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;For the implementation of certain types of servers it is&lt;br/&gt;
desirable to obtain a handle to a newly created file in the form&lt;br/&gt;
of a java.io.OutputStream, which can be used to successively&lt;br/&gt;
write to until the file is closed. A similar request already came&lt;br/&gt;
in June this year, see Peter&apos;s email here:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.listware.net/201006/mongodb-user/17457-mongodb-user-java-driver-obtaining-an-outputstream-for-a-gridfs-file.html&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://www.listware.net/201006/mongodb-user/17457-mongodb-user-java-driver-obtaining-an-outputstream-for-a-gridfs-file.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;or simpler: &lt;a href=&quot;http://ur1.ca/1vfuf&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://ur1.ca/1vfuf&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;I have finished an implementing this addition, and it would be&lt;br/&gt;
good to see it getting into the MongoDB Java API. The&lt;br/&gt;
implementation is compatible to the current Git HEAD and pass all&lt;br/&gt;
unit tests (including two newly made ones for the new feature).&lt;/p&gt;

&lt;p&gt;A Github repository containing the patch along with a pull&lt;br/&gt;
request into the mongo-java-driver main branch can be found here:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://github.com/pohutukawa/mongo-java-driver&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/pohutukawa/mongo-java-driver&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://github.com/mongodb/mongo-java-driver/pull/5&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo-java-driver/pull/5&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;Some information on the implementation:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;The implementation has been aimed at staying backwards compatible with&lt;br/&gt;
previous versions.&lt;/li&gt;
&lt;/ul&gt;


&lt;ul&gt;
	&lt;li&gt;The class GridFS now contains two more createFile() methods, taking no&lt;br/&gt;
parameters and just taking a file name (String). This way I do not have the&lt;br/&gt;
necessity anymore of &lt;b&gt;having&lt;/b&gt; to provide a file/InputStream/byte array object.&lt;/li&gt;
&lt;/ul&gt;


&lt;ul&gt;
	&lt;li&gt;The GridFSInputFile class now offers a public method getOutputStream(). As&lt;br/&gt;
soon as this output stream is obtained, a save() or saveChunks() call will&lt;br/&gt;
only persist the already available input stream data, but the object will&lt;br/&gt;
remain writable on the retrieved output stream until the stream&apos;s close()&lt;br/&gt;
method is called.&lt;/li&gt;
&lt;/ul&gt;


&lt;ul&gt;
	&lt;li&gt;Two further unit tests in GridFSTest are provided to test the output stream&lt;br/&gt;
functionality.&lt;/li&gt;
&lt;/ul&gt;


&lt;ul&gt;
	&lt;li&gt;For all new API methods and &lt;b&gt;all&lt;/b&gt; of GridFSInputFile proper Javadoc is&lt;br/&gt;
provided (it was really tedious to find out things in the beginning with the&lt;br/&gt;
currently very sparse API documentation).&lt;/li&gt;
&lt;/ul&gt;


&lt;ul&gt;
	&lt;li&gt;All wild card imports in the three files have been removed in favour of a&lt;br/&gt;
clean list of individual imports. (Thanks to Eclipse&apos;s &quot;organise imports&quot; that&lt;br/&gt;
was a breeze.) &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/wink.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
                <environment>feature usable for all environments</environment>
        <key id="13323">JAVA-185</key>
            <summary>add OutputStream capability to GridFSInputFile</summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="antoine">Antoine Girbal</assignee>
                                    <reporter username="xemacs">Guy K. Kloss</reporter>
                        <labels>
                    </labels>
                <created>Tue, 12 Oct 2010 01:00:37 +0000</created>
                <updated>Wed, 22 Dec 2010 23:58:14 +0000</updated>
                            <resolved>Thu, 9 Dec 2010 00:24:09 +0000</resolved>
                                                    <fixVersion>2.4</fixVersion>
                                    <component>API</component>
                                        <votes>1</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="21207" author="xemacs" created="Thu, 9 Dec 2010 00:30:57 +0000"  >&lt;p&gt;Sounds good, looking forward to trying it out on my project.&lt;/p&gt;</comment>
                            <comment id="21206" author="antoine" created="Thu, 9 Dec 2010 00:24:09 +0000"  >&lt;p&gt;Thanks Guy, in the end I took your code since it mirrors what we have for GridFSDBFile.&lt;br/&gt;
Some tweaks:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;ability to choose chunkSize before obtaining and OutputStream&lt;/li&gt;
	&lt;li&gt;fix to previous commit: do not save file object in saveChunks()&lt;/li&gt;
	&lt;li&gt;prevent mixed use of inputStream / outputStream in GridFSInputFile&lt;/li&gt;
	&lt;li&gt;better comments on functions&lt;/li&gt;
	&lt;li&gt;added test for writing a gridfs file of a size aligned with chunkSize&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="21197" author="xemacs" created="Wed, 8 Dec 2010 21:17:39 +0000"  >&lt;p&gt;The reason for the implementation like this was two fold: (A) to keep the modifications localised to just the tree files, and (B) to retain maximum backwards compatibility. Feel free to improve, much appreciated. It just seemed to me more likely to be accepted with meeting the conditions (A) and (B).&lt;/p&gt;</comment>
                            <comment id="21183" author="antoine" created="Wed, 8 Dec 2010 18:58:16 +0000"  >&lt;p&gt;I feel like the patch implementation is functional but ends up being messy and confusing for most users, basically it is possible to mix inputstream, outputstream, save(), ...&lt;br/&gt;
I will keep GridFSInputFile and add separate GridFSOutputStream, since method are mostly distinct.&lt;br/&gt;
Also some common code will be moved to GridFSFile. &lt;/p&gt;</comment>
                            <comment id="20099" author="mousehouse" created="Mon, 8 Nov 2010 03:31:29 +0000"  >&lt;p&gt;It will be a wonderful feature.&lt;/p&gt;</comment>
                            <comment id="19096" author="xemacs" created="Tue, 12 Oct 2010 04:29:00 +0000"  >&lt;p&gt;On imports: I agree, that should be discussed elsewhere.&lt;/p&gt;

&lt;p&gt;Kept it compact, only three files:&lt;/p&gt;

&lt;p&gt;src/main/com/mongodb/gridfs/GridFS.java&lt;br/&gt;
src/main/com/mongodb/gridfs/GridFSInputFile.java&lt;br/&gt;
src/test/com/mongodb/gridfs/GridFSTest.java&lt;/p&gt;

&lt;p&gt;The commits were to keep up with the change in your HEAD plus the edits to conform to common style.&lt;/p&gt;

&lt;p&gt;Hope that helps! :o)&lt;/p&gt;</comment>
                            <comment id="19095" author="eliot" created="Tue, 12 Oct 2010 04:12:09 +0000"  >&lt;p&gt;Not going to comment on wild card on this ticket - have to have some semblance of cleanness &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;  As I said, I&apos;m open to discussion.&lt;/p&gt;

&lt;p&gt;Will look at commit again&lt;/p&gt;

&lt;p&gt;Which files did you edit?&lt;/p&gt;

&lt;p&gt;Having trouble reading through since its a number of commits.&lt;/p&gt;

&lt;p&gt;Up for squashing?&lt;/p&gt;</comment>
                            <comment id="19094" author="xemacs" created="Tue, 12 Oct 2010 04:09:07 +0000"  >&lt;p&gt;I&apos;ve tried to manually fix the coding style (re. horizontal white space and imports) into compliance with the rest of the code.&lt;/p&gt;

&lt;p&gt;Regarding the import scheme: This is not really part of this JIRA issue, but as we&apos;re discussing it partly already ...&lt;/p&gt;

&lt;p&gt;The common Java guides as well as common practice state that wildcard imports are not well suited. Particularly for the reason as they get expanded at compile time. So when, say, an import &quot;import com.mongodb.*;&quot; is compiled, it is expanded to import all classes (used or not) into the name space of the code. If now the API of something imported like that changes, the code making use of the wildcard imports will potentially break. So one gains convenience in development for a decreased robustness against used external references. This can be resolved by a simple recompilation (unless other things have changed incompatibly as well), but nonetheless, the binary compatibility has been broken, even though the change in the API wouldn&apos;t necessarily require that to happen. It seems like other developer&apos;s on the mongodb-dev list are feeling equally to encourage a change here. After all, most IDEs nowadays provide support for cleaning up the imports automatically without manual intervention.&lt;/p&gt;</comment>
                            <comment id="19093" author="eliot" created="Tue, 12 Oct 2010 03:37:51 +0000"  >&lt;p&gt;Re: wild cards, the absolute requirement is that the entire code base be consistent.  so changing in some files or with another commit will never get in.&lt;/p&gt;

&lt;p&gt;i&apos;m open to discussion about making a global change - though i&apos;m personally opposed.&lt;/p&gt;</comment>
                            <comment id="19092" author="xemacs" created="Tue, 12 Oct 2010 03:34:01 +0000"  >&lt;p&gt;Yes, I did see as well as use the Eclipse formatting provided by Scott in the repo.&lt;/p&gt;

&lt;p&gt;I don&apos;t know where the alternative formatting comes from, but I can fix at least the indentation/spaces issue. That&apos;s an easy one.&lt;/p&gt;

&lt;p&gt;With the wildcard imports ... Well, that takes manual tinkering, as that&apos;s not done by Eclipse, but rather the reverse.&lt;/p&gt;

&lt;p&gt;On that topic as well: Wildcard imports are largely regarded as harmful, so what&apos;s the religious adherence towards using them, if they make the code more likely to break? See also here:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://javadude.com/articles/importondemandisevil.html&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://javadude.com/articles/importondemandisevil.html&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://www.javaperformancetuning.com/news/qotm031.shtml&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://www.javaperformancetuning.com/news/qotm031.shtml&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If there&apos;d be some documentation on what to wildcard import, and what not, I could much more easily resolve this.&lt;/p&gt;</comment>
                            <comment id="19088" author="eliot" created="Tue, 12 Oct 2010 01:10:36 +0000"  >&lt;p&gt;did you use the eclipse formatting files in the repo?&lt;br/&gt;
this doesn&apos;t obey most of them&lt;br/&gt;
4 spaces&lt;br/&gt;
no tabs&lt;br/&gt;
wildcard imports&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrhcrr:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>14869</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>