You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2017/11/13 17:06:24 UTC
svn commit: r1815119 -
/ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java
Author: jleroux
Date: Mon Nov 13 17:06:24 2017
New Revision: 1815119
URL: http://svn.apache.org/viewvc?rev=1815119&view=rev
Log:
Improved: Fixing defects reported by FindBugs, package
org.apache.ofbiz.base.start.
(OFBIZ-9573)
No functional change, while reviewing r1811413
I noticed we can use a try-with-ress here
Modified:
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java
Modified: ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java?rev=1815119&r1=1815118&r2=1815119&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java Mon Nov 13 17:06:24 2017
@@ -150,21 +150,11 @@ final class StartupControlPanel {
private static void loadGlobalOfbizSystemProperties(String globalOfbizPropertiesFileName) throws StartupException {
String systemProperties = System.getProperty(globalOfbizPropertiesFileName);
if (systemProperties != null) {
- FileInputStream stream = null;
- try {
- stream = new FileInputStream(systemProperties);
- System.getProperties().load(stream);
- stream.close();
+ try { FileInputStream stream = new FileInputStream(systemProperties);
+ System.getProperties().load(stream);
+ stream.close();
} catch (IOException e) {
throw new StartupException("Couldn't load global system props", e);
- } finally {
- try {
- if (stream != null) {
- stream.close();
- }
- } catch (IOException e) {
- System.out.println("There was a problem while closing the Stream " + e);
- }
}
}
}
Re: svn commit: r1815119 -
/ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz
/base/start/StartupControlPanel.java
Posted by Jacques Le Roux <ja...@les7arts.com>.
You were right Michael,
Fixed at revision 1818514.
Like you "I saw too much code in the recent days..." ;-)
;)
Jacques
Le 17/12/2017 à 20:12, Michael Brohl a écrit :
> Hi Jacques,
>
> if I see it right, you have not implemented a try-with-resources block but simply moved the stream declaration inside the try block and removed the
> finally block. Please check.
>
> Thanks,
>
> Michael
>
>
> Am 13.11.17 um 18:06 schrieb jleroux@apache.org:
>> Author: jleroux
>> Date: Mon Nov 13 17:06:24 2017
>> New Revision: 1815119
>>
>> URL: http://svn.apache.org/viewvc?rev=1815119&view=rev
>> Log:
>> Improved: Fixing defects reported by FindBugs, package
>> org.apache.ofbiz.base.start.
>> (OFBIZ-9573)
>>
>> No functional change, while reviewing r1811413
>> I noticed we can use a try-with-ress here
>>
>> Modified:
>> ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java
>>
>> Modified: ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java?rev=1815119&r1=1815118&r2=1815119&view=diff
>> ==============================================================================
>> --- ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java (original)
>> +++ ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java Mon Nov 13 17:06:24 2017
>> @@ -150,21 +150,11 @@ final class StartupControlPanel {
>> private static void loadGlobalOfbizSystemProperties(String globalOfbizPropertiesFileName) throws StartupException {
>> String systemProperties = System.getProperty(globalOfbizPropertiesFileName);
>> if (systemProperties != null) {
>> - FileInputStream stream = null;
>> - try {
>> - stream = new FileInputStream(systemProperties);
>> - System.getProperties().load(stream);
>> - stream.close();
>> + try { FileInputStream stream = new FileInputStream(systemProperties);
>> + System.getProperties().load(stream);
>> + stream.close();
>> } catch (IOException e) {
>> throw new StartupException("Couldn't load global system props", e);
>> - } finally {
>> - try {
>> - if (stream != null) {
>> - stream.close();
>> - }
>> - } catch (IOException e) {
>> - System.out.println("There was a problem while closing the Stream " + e);
>> - }
>> }
>> }
>> }
>>
>>
>
>
Re: svn commit: r1815119 -
/ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java
Posted by Michael Brohl <mi...@ecomify.de>.
Hi Jacques,
if I see it right, you have not implemented a try-with-resources block
but simply moved the stream declaration inside the try block and removed
the finally block. Please check.
Thanks,
Michael
Am 13.11.17 um 18:06 schrieb jleroux@apache.org:
> Author: jleroux
> Date: Mon Nov 13 17:06:24 2017
> New Revision: 1815119
>
> URL: http://svn.apache.org/viewvc?rev=1815119&view=rev
> Log:
> Improved: Fixing defects reported by FindBugs, package
> org.apache.ofbiz.base.start.
> (OFBIZ-9573)
>
> No functional change, while reviewing r1811413
> I noticed we can use a try-with-ress here
>
> Modified:
> ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java
>
> Modified: ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java
> URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java?rev=1815119&r1=1815118&r2=1815119&view=diff
> ==============================================================================
> --- ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java (original)
> +++ ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java Mon Nov 13 17:06:24 2017
> @@ -150,21 +150,11 @@ final class StartupControlPanel {
> private static void loadGlobalOfbizSystemProperties(String globalOfbizPropertiesFileName) throws StartupException {
> String systemProperties = System.getProperty(globalOfbizPropertiesFileName);
> if (systemProperties != null) {
> - FileInputStream stream = null;
> - try {
> - stream = new FileInputStream(systemProperties);
> - System.getProperties().load(stream);
> - stream.close();
> + try { FileInputStream stream = new FileInputStream(systemProperties);
> + System.getProperties().load(stream);
> + stream.close();
> } catch (IOException e) {
> throw new StartupException("Couldn't load global system props", e);
> - } finally {
> - try {
> - if (stream != null) {
> - stream.close();
> - }
> - } catch (IOException e) {
> - System.out.println("There was a problem while closing the Stream " + e);
> - }
> }
> }
> }
>
>