<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:52:30 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-529] NumberFormatException parsing should provide exception subclass or better descriptions</title>
                <link>https://jira.mongodb.org/browse/JAVA-529</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;When trying to JSON.parse() the following String, we get a NumberFormatException. Presumably this is because the number is larger than java.lang.Long.MAX_VALUE.&lt;/p&gt;

&lt;p&gt;{&lt;br/&gt;
    &quot;_id&quot;: &lt;/p&gt;
{
        &quot;$oid&quot;: &quot;4f5535221a880ab3956efea0&quot;
    }
&lt;p&gt;,&lt;br/&gt;
    &quot;foo&quot;: 109997115319321890123&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;java.lang.NumberFormatException: For input string: &quot;109997115319321890123&quot;&lt;br/&gt;
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)&lt;br/&gt;
	at java.lang.Long.parseLong(Long.java:422)&lt;br/&gt;
	at java.lang.Long.valueOf(Long.java:525)&lt;br/&gt;
	at com.mongodb.util.JSONParser.parseNumber(JSON.java:636)&lt;br/&gt;
	at com.mongodb.util.JSONParser.parse(JSON.java:370)&lt;br/&gt;
	at com.mongodb.util.JSONParser.parseObject(JSON.java:414)&lt;br/&gt;
	at com.mongodb.util.JSONParser.parse(JSON.java:378)&lt;br/&gt;
	at com.mongodb.util.JSONParser.parse(JSON.java:328)&lt;br/&gt;
	at com.mongodb.util.JSON.parse(JSON.java:287)&lt;/p&gt;</description>
                <environment>Java 6 on Mac OS X 10.7.3 (Lion)</environment>
        <key id="32291">JAVA-529</key>
            <summary>NumberFormatException parsing should provide exception subclass or better descriptions</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</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="bryan.reinero">Bryan Reinero</assignee>
                                    <reporter username="jared">Jared D. Cottrell</reporter>
                        <labels>
                    </labels>
                <created>Tue, 6 Mar 2012 00:36:55 +0000</created>
                <updated>Wed, 3 Feb 2016 18:07:16 +0000</updated>
                            <resolved>Wed, 28 Mar 2012 14:19:42 +0000</resolved>
                                    <version>2.7.3</version>
                                    <fixVersion>2.8.0</fixVersion>
                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="1162609" author="jeff.yemin" created="Wed, 3 Feb 2016 18:07:16 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=aleksey.korolev&quot; class=&quot;user-hover&quot; rel=&quot;aleksey.korolev&quot;&gt;aleksey.korolev&lt;/a&gt;  This issue is closed, so we won&apos;t be doing anything further with it.  As what you&apos;re asking for seems to be a feature request, please open a new issue if you&apos;d like to see it addressed.  But before you do that, please consider:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Converting to String would silently change the value type&lt;/li&gt;
	&lt;li&gt;Converting to BigInteger or BigDecimal is a possibility, but currently the driver is not able to encode either of those into BSON, as there is no BSON type large enough to hold a number larger than a long or double.&lt;/li&gt;
	&lt;li&gt;An upcoming version of MongoDB will support 128-bit decimal values, which may be large enough to hold your numbers.&lt;/li&gt;
&lt;/ul&gt;

</comment>
                            <comment id="1162505" author="aleksey.korolev" created="Wed, 3 Feb 2016 17:07:56 +0000"  >&lt;p&gt;Just caught this exception on MongoDB 3.2 when the number was too big for java.lang.Long and behavior was unexpected for me.&lt;br/&gt;
How about rethinking this to not fail but rather parse such numbers as String or BigInteger, may be with help of options passed to parse method?&lt;/p&gt;</comment>
                            <comment id="134070" author="jeff.yemin" created="Mon, 18 Jun 2012 19:36:13 +0000"  >&lt;p&gt;Closing for 2.8.0 release.&lt;/p&gt;</comment>
                            <comment id="104293" author="bryan.reinero@10gen.com" created="Wed, 28 Mar 2012 14:19:42 +0000"  >&lt;p&gt;This change may impact applications which have been coded explicitly to catch NumberFormatExceptions. These applications should instead catch JSONParseExceptions.&lt;/p&gt;</comment>
                            <comment id="104290" author="auto" created="Wed, 28 Mar 2012 14:05:12 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;breinero&apos;, u&apos;name&apos;: u&apos;Bryan Reinero&apos;, u&apos;email&apos;: u&apos;bryan.reinero@10gen.com&apos;}
&lt;p&gt;Message: Jira ticket; &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-529&quot; title=&quot;NumberFormatException parsing should provide exception subclass or better descriptions&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-529&quot;&gt;&lt;del&gt;JAVA-529&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
NumberFormatException thrown within method parseNumber&lt;br/&gt;
is now caught and chained as a JSONParseException&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/49b7788c8a2276d6404e298880f5e424ff504585&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/49b7788c8a2276d6404e298880f5e424ff504585&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="95613" author="jeff.yemin" created="Tue, 6 Mar 2012 01:27:08 +0000"  >&lt;p&gt;How about we wrap the NumberFormatException in a com.mongodb.util.JSONParseException, which already exists and is thrown for other parsing errors.&lt;/p&gt;</comment>
                            <comment id="95610" author="scotthernandez" created="Tue, 6 Mar 2012 01:11:25 +0000"  >&lt;p&gt;All numbers in javascript are fp (64bit) by default. NumberLong is what you want if you want a signed int (64bit).&lt;/p&gt;</comment>
                            <comment id="95609" author="jared" created="Tue, 6 Mar 2012 01:07:13 +0000"  >&lt;p&gt;Though there does seem to be some inconsistency with how the shell behaves. It will take the number without error, but rounds it. I assume it&apos;s turning it into a floating point number.&lt;/p&gt;


&lt;p&gt;&amp;gt; db.stuff.save(&lt;/p&gt;
{&quot;foo&quot;: 109997115319321890123}
&lt;p&gt;)&lt;br/&gt;
&amp;gt; db.stuff.find()&lt;/p&gt;
{ &quot;_id&quot; : ObjectId(&quot;4f5560695d4a54c0b7ae6a76&quot;), &quot;foo&quot; : 109997115319321890000 }</comment>
                            <comment id="95606" author="jared" created="Tue, 6 Mar 2012 01:02:46 +0000"  >&lt;p&gt;It would be helpful to have descriptive text as well as an Exception subclass that can reliably be filtered on to pull out user-readable messages.&lt;/p&gt;

&lt;p&gt;So, one solution might be to throw InvalidJsonExceptions where the message can be counted on to be clean and in this case might say, &quot;The number \&quot;109997115319321890123\&quot; is too large to be stored.&quot;&lt;/p&gt;</comment>
                            <comment id="95603" author="scotthernandez" created="Tue, 6 Mar 2012 00:53:26 +0000"  >&lt;p&gt;How would you like this to be handled? An error the number is too long and can&apos;t be stored? Or invalid?&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10011"><![CDATA[Minor 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|hrhbaf:</customfieldvalue>

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