The NumberFormatException is not in any catch sentence but if parseInt throw the NumberFormatException the SQLException | ClassNotFoundException catch block is running (I can't figure why), if I rewrite the code:

Re: Multiple catch bug?

I interpret differently: in your first example the parseInt() is not causing an exception, so the code goes on to the f.save(), blows up and throws an SQLException. In stead of hiding the information, add printStackTrace() calls to your exception handling blocks and see the actual exception that is being caused and by which statement.

Re: Multiple catch bug?

Originally Posted by gimbal2

I interpret differently: in your first example the parseInt() is not causing an exception, so the code goes on to the f.save(), blows up and throws an SQLException. In stead of hiding the information, add printStackTrace() calls to your exception handling blocks and see the actual exception that is being caused and by which statement.

I get the stacktrace it says:

Java Code:

java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:592)
at java.lang.Integer.parseInt(Integer.java:615)
at cl.pollero.controladores.CrearFamiliaController.lambda$configurarBotonCrear$1(CrearFamiliaController.java:92)
...

the line with the:

Java Code:

f.setStock(Integer.parseInt(tflStock.getText()));

any way, if you ask me the two snipped code (multiple catch and one catch at time) are the same, but they work differently, I'm using Java 8, may be a bug?

Re: Multiple catch bug?

I can't say, I'm not a developer on the Java 8 development team and I am not going to consider using it before it has been officially released and had at least two patch releases. If you can produce a small test application which shows the problem, I'll be happy to take a look running it through Java 7.