My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
  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, May 24, 2010
As I see in library code:
        public static Object parse(Reader in){
                        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:
    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.:
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
Yes there are some issues with parse() and it is for backward compatibility only now.
Please use parseWithException() instead.
Status: WontFix
May 24, 2010
In this case you probably should mark 
 public static Object parse(Reader in){
method as:
May 24, 2010
Project Member #3
Status: Accepted
Aug 9, 2013
Project Member #4
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