Steve Haslam (araqnid) wrote,
Steve Haslam
araqnid

  • Mood:
  • Music:

confusing error messages

Got handed an exception backtrace that contained:
Caused by: java.lang.NumberFormatException: null
	at java.lang.Integer.parseInt(Ljava.lang.String;I)I(Unknown Source)
	at java.lang.Integer.(Ljava.lang.String;)V(Unknown Source)
basically, we're parsing a String to an integer using "new Integer(string)": there was already a check in place for string being non-null further up the stack, so WTF? One thing I checked was exactly what happens if you do "new Integer("null")", because this has the potential for being very confusing. You get:
1) test1(com.lastminute.workflow.X)java.lang.NumberFormatException: For input string: "null"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
        at java.lang.Integer.parseInt(Integer.java:468)
        at java.lang.Integer.(Integer.java:609)
in contrast to
2) test2(com.lastminute.workflow.X)java.lang.NumberFormatException: null
        at java.lang.Integer.parseInt(Integer.java:436)
        at java.lang.Integer.(Integer.java:609)
After much barking around, finally realised I was running the test under a different JVM to what we use for running production services. And guess what?
3) test1(com.lastminute.workflow.X)java.lang.NumberFormatException: null
        at java.lang.Integer.parseInt(Ljava.lang.String;I)I(Unknown Source)
        at java.lang.Integer.(Ljava.lang.String;)V(Unknown Source)

2) test2(com.lastminute.workflow.X)java.lang.NumberFormatException: null
        at java.lang.Integer.parseInt(Ljava.lang.String;I)I(Unknown Source)
        at java.lang.Integer.(Ljava.lang.String;)V(Unknown Source)
Arguably I should use the same JVM for testing and development that we used for deployed services... but the Sun one has the source code to the standard libraries too which makes it nicer to use with Eclipse.... *sigh*
Tags: geek
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 2 comments