[jira] [Comment Edited] (OFBIZ-8115) Fixe a bunch of small leaks (closes missing, reported as warnings in Eclipse)

2016-09-02 Thread Jacques Le Roux (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-8115?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15458508#comment-15458508
 ] 

Jacques Le Roux edited comment on OFBIZ-8115 at 9/2/16 1:27 PM:


*Point 1)*
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 (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 for that today.

Done at revision: 1758951



was (Author: jacques.le.roux):
*Point 1)*
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 (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.

Done at revision: 1758951


> Fixe a bunch of small leaks (closes missing, reported as warnings in Eclipse)
> -
>
> Key: OFBIZ-8115
> URL: https://issues.apache.org/jira/browse/OFBIZ-8115
> Project: OFBiz
>  Issue Type: Improvement
>  Components: ALL COMPONENTS
>Affects Versions: Trunk
>Reporter: Jacques Le Roux
>Assignee: Jacques Le Roux
>Priority: Minor
> Fix For: Upcoming Branch
>
>
> At r1758927 I tried to fixe a bunch of closes missing, reported as warnings 
> in Eclipse
> Jacopo noticed and reported on dev ML 
> http://markmail.org/message/b4hvzi7foftfq3j5 2 possible issues:
> # 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 suspect that you are closing the socket connection too early in 
> PcChargeApi
> So I reverted r1758927 to check the issues



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Comment Edited] (OFBIZ-8115) Fixe a bunch of small leaks (closes missing, reported as warnings in Eclipse)

2016-09-02 Thread Jacques Le Roux (JIRA)

[ 
https://issues.apache.org/jira/browse/OFBIZ-8115?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15458254#comment-15458254
 ] 

Jacques Le Roux edited comment on OFBIZ-8115 at 9/2/16 11:38 AM:
-

I see no problem with the point 2, but the point 1 is more complex (I wonder 
why Eclipse would be wrong) and I'll double check all details...


was (Author: jacques.le.roux):
I see not problem with the point 2, but the point 1 is more complex (I wonder 
why Eclipse would be wrong) and I'll double check all details...

> Fixe a bunch of small leaks (closes missing, reported as warnings in Eclipse)
> -
>
> Key: OFBIZ-8115
> URL: https://issues.apache.org/jira/browse/OFBIZ-8115
> Project: OFBiz
>  Issue Type: Improvement
>  Components: ALL COMPONENTS
>Affects Versions: Trunk
>Reporter: Jacques Le Roux
>Assignee: Jacques Le Roux
>Priority: Minor
> Fix For: Upcoming Branch
>
>
> At r1758927 I tried to fixe a bunch of closes missing, reported as warnings 
> in Eclipse
> Jacopo noticed and reported on dev ML 
> http://markmail.org/message/b4hvzi7foftfq3j5 2 possible issues:
> # 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 suspect that you are closing the socket connection too early in 
> PcChargeApi
> So I reverted r1758927 to check the issues



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)