[JAVA-446] Possible bug with JSON parser Created: 07/Oct/11  Updated: 27/Feb/13  Resolved: 27/Feb/13

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: 2.5.3
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Jeff Yemin (Inactive) Assignee: Bryan Reinero
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates JAVA-672 JSON.parse should throw an exception ... Closed

 Description   

It seems strange that this test passes, but it does:

    @org.junit.Test
    public void testJSONParseOfPartialLong() {
        Object obj = com.mongodb.util.JSON.parse("666 is the devil");
        Assert.assertEquals(Long.valueOf(666), obj);
    }

We happen to be using that method to parse a query parameter to one of our REST endpoints, and it bit us. Should it not throw a JSONParseException instead of swallowing " is the devil" silently?



 Comments   
Comment by Jeffrey Yemin [ 27/Feb/13 ]

This was closed in error

Comment by Jeffrey Yemin [ 12/Aug/12 ]

Looks like you never pushed this.

Comment by Bryan Reinero [ 13/Jun/12 ]

fix in code review (http://codereview.10gen.com/7952014/), but not yet merged into master as the branch is frozen while version 2.8 is a release candidate

Comment by Jeff Yemin (Inactive) [ 07/Oct/11 ]

This also does not throw an exception:

com.mongodb.util.JSON.parse("{\"val\" : 666} 666");

FWIW, I also tried both cases with the Jackson JSON library, and it works exactly the same.

Generated at Thu Feb 08 08:52:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.