<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:55:29 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-1785] ObjectId.compareTo() returns wrong response</title>
                <link>https://jira.mongodb.org/browse/JAVA-1785</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;I have 2 long values &lt;span class=&quot;error&quot;&gt;&amp;#91;100, 200&amp;#93;&lt;/span&gt;, with which I create two ObjectId objects, using a byte array&lt;br/&gt;
byte1 = byte [] bytes = ByteBuffer.allocate(12).putLong(value1).put(new byte&lt;span class=&quot;error&quot;&gt;&amp;#91;4&amp;#93;&lt;/span&gt;).array()&lt;br/&gt;
objectId1 = ObjectId(byte1)&lt;/p&gt;

&lt;p&gt;This constructs the following two ObjectIds:&lt;br/&gt;
obj1 = 000000000000006400000000&lt;br/&gt;
obj2 = 00000000000000c800000000&lt;/p&gt;

&lt;p&gt;When i try to compare: obj1.compareTo(obj2)&amp;lt;0 the result is false&lt;br/&gt;
This happens because obj1&apos;s processIdentifier value (bytes &quot;6400&quot;) is set to value &quot;25600&quot;, while the obj2&apos;s processIdentifier value (bytes &quot;c800&quot;) is set to the signed &quot;-14336&quot;.&lt;br/&gt;
So the comparison &quot;x = processIdentifier - other.processIdentifier;&quot; is positive and obj1.compareTo(obj2)&amp;lt;0 returns false.&lt;/p&gt;

&lt;p&gt;In v2.x.x versions of the driver, there was a &quot;_compareUnsigned&quot; operation, for handling these comparisons.&lt;/p&gt;

&lt;p&gt;Is this a bug or this is the way it should work now?&lt;/p&gt;</description>
                <environment>JDK 7.0_51</environment>
        <key id="200951">JAVA-1785</key>
            <summary>ObjectId.compareTo() returns wrong response</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</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="ross@mongodb.com">Ross Lawley</assignee>
                                    <reporter username="pkranas">Pavlos Kranas</reporter>
                        <labels>
                            <label>regression</label>
                    </labels>
                <created>Wed, 29 Apr 2015 10:43:01 +0000</created>
                <updated>Sun, 18 Nov 2018 00:26:34 +0000</updated>
                            <resolved>Thu, 30 Apr 2015 08:11:32 +0000</resolved>
                                    <version>3.0.0</version>
                                    <fixVersion>3.0.1</fixVersion>
                                    <component>BSON</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="905762" author="jeff.yemin" created="Tue, 5 May 2015 19:38:43 +0000"  >&lt;p&gt;Closed for 3.0.1 release.&lt;/p&gt;</comment>
                            <comment id="901843" author="xgen-internal-githook" created="Thu, 30 Apr 2015 08:53:05 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;rozza&apos;, u&apos;name&apos;: u&apos;Ross Lawley&apos;, u&apos;email&apos;: u&apos;ross.lawley@gmail.com&apos;}
&lt;p&gt;Message: Fix ObjectId compareTo for Java 6&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-1785&quot; title=&quot;ObjectId.compareTo() returns wrong response&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-1785&quot;&gt;&lt;del&gt;JAVA-1785&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/1a0549c8d74925d02df5a56ea9ee44a0d71751c9&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/1a0549c8d74925d02df5a56ea9ee44a0d71751c9&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="901841" author="xgen-internal-githook" created="Thu, 30 Apr 2015 08:52:49 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;rozza&apos;, u&apos;name&apos;: u&apos;Ross Lawley&apos;, u&apos;email&apos;: u&apos;ross.lawley@gmail.com&apos;}
&lt;p&gt;Message: Fix ObjectId compareTo for Java 6&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-1785&quot; title=&quot;ObjectId.compareTo() returns wrong response&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-1785&quot;&gt;&lt;del&gt;JAVA-1785&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: 3.0.x&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/0db294195fb3adb31caf7bc75b01d716a7dfc6ab&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/0db294195fb3adb31caf7bc75b01d716a7dfc6ab&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="901829" author="xgen-internal-githook" created="Thu, 30 Apr 2015 08:12:01 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;rozza&apos;, u&apos;name&apos;: u&apos;Ross Lawley&apos;, u&apos;email&apos;: u&apos;ross.lawley@gmail.com&apos;}
&lt;p&gt;Message: Fix regression in ObjectId.compareTo&lt;/p&gt;

&lt;p&gt;Now checks the byte array unsigned int values&lt;br/&gt;
&lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-1785&quot; title=&quot;ObjectId.compareTo() returns wrong response&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-1785&quot;&gt;&lt;del&gt;JAVA-1785&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/19e6f77e55bce8837c70da05df358eb7114d8c48&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/19e6f77e55bce8837c70da05df358eb7114d8c48&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="901828" author="ross@10gen.com" created="Thu, 30 Apr 2015 08:11:32 +0000"  >&lt;p&gt;Thanks for reporting &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=+pkranas&quot; class=&quot;user-hover&quot; rel=&quot; pkranas&quot;&gt; pkranas&lt;/a&gt;. This has been fixed and will be released in 3.0.1&lt;/p&gt;</comment>
                            <comment id="901827" author="xgen-internal-githook" created="Thu, 30 Apr 2015 08:10:47 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;rozza&apos;, u&apos;name&apos;: u&apos;Ross Lawley&apos;, u&apos;email&apos;: u&apos;ross.lawley@gmail.com&apos;}
&lt;p&gt;Message: Fix regression in ObjectId.compareTo&lt;/p&gt;

&lt;p&gt;Now checks the byte array unsigned int values&lt;br/&gt;
&lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-1785&quot; title=&quot;ObjectId.compareTo() returns wrong response&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-1785&quot;&gt;&lt;del&gt;JAVA-1785&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: 3.0.x&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/3a4b24ecea03b76d7c3dac1398d94a6ef5a6ceed&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/3a4b24ecea03b76d7c3dac1398d94a6ef5a6ceed&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="900842" author="ross@10gen.com" created="Wed, 29 Apr 2015 13:18:09 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=pkranas&quot; class=&quot;user-hover&quot; rel=&quot;pkranas&quot;&gt;pkranas&lt;/a&gt;, my apologies - I do believe this is a regression and counter to how the server compares the ObjectId&apos;s.&lt;/p&gt;

&lt;p&gt;Will confirm and update shortly.&lt;/p&gt;</comment>
                            <comment id="900801" author="pkranas" created="Wed, 29 Apr 2015 12:11:27 +0000"  >&lt;p&gt; Hi Ross,&lt;/p&gt;

&lt;p&gt; Thanx for your quick reply &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;&lt;/p&gt;

&lt;p&gt; I understood what u wrote to me, however my point was that until &lt;br/&gt;
 v.13.0, the ObjectId&apos;s compareTo() was using unsigned short types for &lt;br/&gt;
 making the comparisons between ObjectID&apos;s subtypes. The &lt;br/&gt;
 &apos;_compareUnsigned&apos; method was invoked in order to explicitly transform a &lt;br/&gt;
 signed type to unsigned and then perform the comparison (see line 374, &lt;br/&gt;
 387 of the attached).&lt;/p&gt;

&lt;p&gt; So from your answer I can assume that this will no longer stand for &lt;br/&gt;
 v3.x.x and I have to provide only signed values for the various &lt;br/&gt;
 ObjectId&apos;s subtypes, right?&lt;/p&gt;

&lt;p&gt; Thanx in advance for your time,&lt;br/&gt;
 Pavlos&lt;/p&gt;


</comment>
                            <comment id="900765" author="ross@10gen.com" created="Wed, 29 Apr 2015 11:49:21 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=pkranas&quot; class=&quot;user-hover&quot; rel=&quot;pkranas&quot;&gt;pkranas&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;In 3.0.0 &lt;tt&gt;ObjectId&lt;/tt&gt; was bought up to specification in : &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-749&quot; title=&quot;Make ObjectId conform to specification&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-749&quot;&gt;&lt;del&gt;JAVA-749&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;An ObjectId is a 12-byte BSON type, constructed using:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;a 4-byte value representing the seconds since the Unix epoch,&lt;/li&gt;
	&lt;li&gt;a 3-byte machine identifier,&lt;/li&gt;
	&lt;li&gt;a 2-byte process id, and&lt;/li&gt;
	&lt;li&gt;a 3-byte counter, starting with a random value.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;So from your example the bytes are: &lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;byte1 = new byte[]{0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0}&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;byte2 = new byte[]{0, 0, 0, 0, 0, 0,  -56, 0, 0, 0, 0, 0}&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;So from that we get the respective processIdentifier&apos;s and  so I would expect that:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;assert(objectId1.compareTo(objectId2) &amp;gt; 0);&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;
</comment>
                    </comments>
                    <attachments>
                            <attachment id="72291" name="ObjectId.java" size="20195" author="pkranas" created="Wed, 29 Apr 2015 12:11:27 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10012"><![CDATA[Major Change]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <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|hs8pvb:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="521">Java Sprint 19</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>