Monthly Archives: October 2011

Problem created, problem solved

Many thanks to Emanuele for submitting the code.

This is how you create the problem:

   Long.parseLong(Long.toString(id.longValue()));



And this is how you’re going to solve it:

   try {
           mId = Long.parseLong(Long.toString(id.longValue()));
           log.debug("id: " + id.longValue());
       } catch (NullPointerException npEx) {
           log.debug("NullPointerException npEx :: " + npEx.getMessage());
           return ActionSupport.ERROR;
       } catch (NumberFormatException nfEx) {
           log.debug("NumberFormatException nfEx :: " + nfEx.getMessage());
           return ActionSupport.ERROR;
       } catch (Exception gnEx) {
           log.debug("Exception gnEx :: " + gnEx.getMessage());
           return ActionSupport.ERROR;
       }

Someone said “If you are not part of the solution then you are part of the problem”.
The guy who has wrote this chunk of code, eventually is part of both.