• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

InvocationTargetException: For input string [DONE]

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've upgraded templates and classes to the current CVS.

I've got this:



When opening a topic. But the topic was opened anyway (everything seems OK). I've tried three times.
[originally posted on jforum.net by Daniil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I'll change PostVH.java like this:



Or maybe a NumberFormatException case should be logged to catch possible bugs...
[originally posted on jforum.net by Daniil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Patch is here, however you may want to add some logging to the catch(NFE) block I think.

http://dan.solutions.lv/jforum/patches/
[originally posted on jforum.net by Daniil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try-cath is not a solution ;)

Please get PostVH.java again from CVS.. I fixed this bug.

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rafael Steil wrote:try-cath is not a solution ;)


That's what exceptions are for - get rid of the hundreds of error-checking if()'s. OK, so


if (s != "") {
start = Integer.parseInt(s);
}


And what if s == "laskdjfhkasdjfh"?

I suppose passing empty start is a bug in JForum anyway.
[originally posted on jforum.net by Daniil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniil wrote:

Rafael Steil wrote:try-cath is not a solution ;)


That's what exceptions are for - get rid of the hundreds of error-checking



NullPointerException is a bug in your code and must be handled in the correct way. When an exception occur, the VM must get the entine call stack, generate messages, stop processing and so on. This is very costing, and worst, using empty try-catch blocks, you will never know that the bug is occuring ( logging may be an option, but when will look at the web server log? ;) ).

Daniil wrote:
if()'s. OK, so


if (s != "") {
start = Integer.parseInt(s);
}


And what if s == "laskdjfhkasdjfh"?

I suppose passing empty start is a bug in JForum anyway.



ops. s != "" is bogus uaheuaheuahe.. sorry.. It must be !s.equals("") ..
And yes, start must not be empty, but we should make the validation ( and not expect for the exception ).

Anyway, where this bug was thrown?

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't get a deeper stack trace (need some black magic with tomcat config)?

As for NPE, that's certainly not a bug in this case: getting no "start" parameter from the browser request is perfectly valid...
[originally posted on jforum.net by Daniil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rafael Steil wrote:ops. s != "" is bogus uaheuaheuahe.. sorry.. It must be !s.equals("") ..


A chance to get an NPE here (if s was not checked for null before). So probably "".equals(s) is a little bit better, or maybe not, depending on the coder's intent (you ).
[originally posted on jforum.net by Daniil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniil wrote:I can't get a deeper stack trace (need some black magic with tomcat config)?



I mean, which page / action you was doing? the stack trace is not necessary..

Daniil wrote:
As for NPE, that's certainly not a bug in this case: getting no "start" parameter from the browser request is perfectly valid...



Is valid from the point of view that is may occur. So it means that the code must be able to handle this situation.

Rafael


[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rafael Steil wrote:

Daniil wrote:I can't get a deeper stack trace (need some black magic with tomcat config)?



I mean, which page / action you was doing? the stack trace is not necessary..


I've just opened a new topic with a post (subj. "test", body "test"). A reply did trigger this bug too. So it feels like any posting action from me was trigging it (not sure about post editing through).
[originally posted on jforum.net by Daniil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Daniil..

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wish I could really help... :roll:
[originally posted on jforum.net by Daniil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Relax

I made this bug last night, is not hard to fix it, was just a little of distraction.
You *are* helping a lot

Rafael
[originally posted on jforum.net by Rafael Steil]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!