Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-529

NumberFormatException parsing should provide exception subclass or better descriptions

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.8.0
    • Affects Version/s: 2.7.3
    • Component/s: None
    • Labels:
      None
    • Environment:
      Java 6 on Mac OS X 10.7.3 (Lion)
    • Minor Change

      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.

      {
      "_id":

      { "$oid": "4f5535221a880ab3956efea0" }

      ,
      "foo": 109997115319321890123
      }

      java.lang.NumberFormatException: For input string: "109997115319321890123"
      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
      at java.lang.Long.parseLong(Long.java:422)
      at java.lang.Long.valueOf(Long.java:525)
      at com.mongodb.util.JSONParser.parseNumber(JSON.java:636)
      at com.mongodb.util.JSONParser.parse(JSON.java:370)
      at com.mongodb.util.JSONParser.parseObject(JSON.java:414)
      at com.mongodb.util.JSONParser.parse(JSON.java:378)
      at com.mongodb.util.JSONParser.parse(JSON.java:328)
      at com.mongodb.util.JSON.parse(JSON.java:287)

            Assignee:
            bryan.reinero Bryan Reinero
            Reporter:
            jared Jared D. Cottrell
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: