Re: svn commit: r1815119 - /ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r1815119 - /ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java

Michael Brohl-3
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 [hidden email]:

> 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);
> -                }
>               }
>           }
>       }
>
>


smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r1815119 - /ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz /base/start/StartupControlPanel.java

Jacques Le Roux
Administrator
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 [hidden email]:
>> 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);
>> -                }
>>               }
>>           }
>>       }
>>
>>
>
>