?

Log in

No account? Create an account

Previous Entry | Next Entry

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:

Comments

( 2 comments — Leave a comment )
inferis
Sep. 30th, 2005 01:47 pm (UTC)
But why would you possibly end up with the string "null"? I take it the first backtrace is from the production environment, attached to a bug report or something?
araqnid
Sep. 30th, 2005 02:12 pm (UTC)
Yes, "null" ended up in the database, hence getting the first backtrace in a bug report. Or rather, in an email saying "Steve, WTF is going on?". Having "null" as the value is completely wrong too, but unfortunately the code doesn't do the sensible thing and delete the corresponding row when a null value is set... and that causes this and.. ick.
( 2 comments — Leave a comment )

Profile

araqnid
Steve Haslam

Latest Month

March 2009
S M T W T F S
1234567
891011121314
15161718192021
22232425262728
293031    

Page Summary

Powered by LiveJournal.com
Designed by Tiffany Chow