You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ju...@apache.org on 2021/01/11 18:56:37 UTC

[jspwiki] 01/08: remove unneeded 'new File(..)' + add Exception thrown to stacktrace if unable to load jspwiki.properties file

This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 1dee73688991286bd1944b847e760312b8f0d192
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Mon Jan 11 18:22:12 2021 +0100

    remove unneeded 'new File(..)' + add Exception thrown to stacktrace if unable to load jspwiki.properties file
---
 .../src/main/java/org/apache/wiki/util/PropertyReader.java       | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/jspwiki-util/src/main/java/org/apache/wiki/util/PropertyReader.java b/jspwiki-util/src/main/java/org/apache/wiki/util/PropertyReader.java
index bf06e7d..018b4fc 100644
--- a/jspwiki-util/src/main/java/org/apache/wiki/util/PropertyReader.java
+++ b/jspwiki-util/src/main/java/org/apache/wiki/util/PropertyReader.java
@@ -23,7 +23,6 @@ import org.apache.commons.lang3.Validate;
 import org.apache.log4j.Logger;
 
 import javax.servlet.ServletContext;
-import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -112,7 +111,7 @@ public final class PropertyReader {
         try( final InputStream propertyStream = loadCustomPropertiesFile(context, propertyFile) ) {
             final Properties props = getDefaultProperties();
             if( propertyStream == null ) {
-                LOG.info("No custom property file found, relying on JSPWiki defaults.");
+                LOG.info( "No custom property file found, relying on JSPWiki defaults." );
             } else {
                 props.load( propertyStream );
             }
@@ -128,7 +127,7 @@ public final class PropertyReader {
 
             return props;
         } catch( final Exception e ) {
-            LOG.error( "JSPWiki: Unable to load and setup properties from jspwiki.properties. " + e.getMessage() );
+            LOG.error( "JSPWiki: Unable to load and setup properties from jspwiki.properties. " + e.getMessage(), e );
         }
 
         return null;
@@ -150,7 +149,7 @@ public final class PropertyReader {
 		    propertyStream =  locateClassPathResource(context, CUSTOM_JSPWIKI_CONFIG);
 		} else {
 		    LOG.info( PARAM_CUSTOMCONFIG + " defined, using " + propertyFile + " as the custom properties file." );
-		    propertyStream = new FileInputStream( new File(propertyFile) );
+		    propertyStream = new FileInputStream( propertyFile );
 		}
 		return propertyStream;
 	}
@@ -229,7 +228,7 @@ public final class PropertyReader {
                 break;
             }
 
-            try( final InputStream propertyStream = new FileInputStream( new File( propertyFile ) ) ) {
+            try( final InputStream propertyStream = new FileInputStream( propertyFile ) ) {
                 LOG.info( " Reading additional properties from " + propertyFile + " and merge to cascade." );
                 final Properties additionalProps = new Properties();
                 additionalProps.load( propertyStream );