My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 24: Wrong Exception handling
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Aug 2013


Sign in to add a comment
 
Reported by dmitry.s...@gmail.com, May 24, 2010
As I see in library code:
https://code.google.com/p/json-simple/source/browse/trunk/src/org/json/simple/JSONValue.java#39
{{{
        public static Object parse(Reader in){
                try{
                        JSONParser parser=new JSONParser();
                        return parser.parse(in);
                }
                catch(Exception e){
                        return null;
                }
        }
}}}
The idea is to return some value or null if some problem happened,
no matter RuntimeException or Checked Exception.

But code in parser may throw Error:
https://code.google.com/p/json-simple/source/browse/trunk/src/org/json/simple/parser/Yylex.java#474
{{{
    throw new Error(message);
}}}
so catch-block: "catch(Exception e)" will not catch Error, and
user, me, will get some Error exception in code.

The idea of errors, as far as I know is to highlight SIGNIFICANT
problems in application, when application probably can not work
any more, e.g.:
http://java.sun.com/javase/6/docs/api/java/lang/NoClassDefFoundError.html
Application can not run if some code is not found.

But Error from json_simple may be thrown even on invalid input string,
which, I think, should be handled as some sort of RuntimeException.




May 24, 2010
Project Member #1 fangyid...@gmail.com
Yes there are some issues with parse() and it is for backward compatibility only now.
Please use parseWithException() instead.
Status: WontFix
May 24, 2010
#2 dmitry.s...@gmail.com
In this case you probably should mark 
 public static Object parse(Reader in){
method as:
 @Deprectaed
May 24, 2010
Project Member #3 fangyid...@gmail.com
Thanks. 
Status: Accepted
Aug 9, 2013
Project Member #4 jon.cham...@gmail.com
Marked as @deprecated in r212. Sadly, we're trying to stick to JDK 1.2 for 1.x, so the @deprecated marker is only in Javadoc instead of actually being applied as an annotation.
Status: Fixed
Sign in to add a comment

Powered by Google Project Hosting