Le 02/09/2016 à 12:30, Jacopo Cappellato a écrit :
1) you are adding a close statement to code that already had the close
statement in the "finally" block; your modification actually introduces a
code pattern that is not correct (if an exception is thrown your close
statement are not executed)
I guess you spoke about DatabaseUtil.java
The best option when closing resources (which implement|AutoCloseable) |is actually to use the try-with-resources statement. At least when there are
no performance issues.
I have fixed the issue you reported (was only in DatabaseUtil.java) this way
because
* there are not performance issues, we anyway create a Statement in both
cases, we don't reuse one.
* the finally part is cleaner
I have also used the try-with-resources statement in other places where it
fitted.
There is only 1 place where I was undecided: ScriptUtil.parseScript() which
uses GroovyUtil.parseClass().
I put only a logError() there and returned null.
I did not throw an IOException because else it spreads everywhere in
FlexibleStringExpander.
Here introducing Optional would be better, but I have no time or that today.
2) I suspect that you are closing the socket connection too early
in PcChargeApi
I see no problem with this point, the "sock" socket connection is not used in
code below.
I have created https://issues.apache.org/jira/browse/OFBIZ-8115 for that and
committed my work at
I'll continue to carefully clean stuff Eclipse reports
Jacques