This is an automated email from the ASF dual-hosted git repository.
rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwebbeans.git
The following commit(s) were added to refs/heads/master by this push:
new d08def3 [MEECROWAVE-264] ensure we don't init the propertyloader
logger until we actually need it otherwise it can be wrongly initialized if
used to load configuration
d08def3 is described below
commit d08def38f8968096782ba3938b1499cd3a7530b3
Author: Romain Manni-Bucau <[email protected]>
AuthorDate: Mon Oct 26 19:10:17 2020 +0100
[MEECROWAVE-264] ensure we don't init the propertyloader logger until we
actually need it otherwise it can be wrongly initialized if used to load
configuration
---
.../org/apache/webbeans/config/PropertyLoader.java | 23 ++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git
a/webbeans-impl/src/main/java/org/apache/webbeans/config/PropertyLoader.java
b/webbeans-impl/src/main/java/org/apache/webbeans/config/PropertyLoader.java
index 5a59ff0..0b46eb0 100644
--- a/webbeans-impl/src/main/java/org/apache/webbeans/config/PropertyLoader.java
+++ b/webbeans-impl/src/main/java/org/apache/webbeans/config/PropertyLoader.java
@@ -44,10 +44,7 @@ public final class PropertyLoader
public static final int CONFIGURATION_ORDINAL_DEFAULT_VALUE = 100;
public static final String CONFIGURATION_ORDINAL_PROPERTY_NAME =
"configuration.ordinal";
-
-
- private static final Logger logger =
WebBeansLoggerFacade.getLogger(PropertyLoader.class);
-
+ private static Logger logger; // don't eager init it otherwise
properlyloader can't be reused (meecrowave)
private PropertyLoader()
{
@@ -92,7 +89,8 @@ public final class PropertyLoader
}
catch (IOException e)
{
- logger.log(Level.SEVERE, "Error while loading the propertyFile " +
propertyFileName, e);
+ getLogger()
+ .log(Level.SEVERE, "Error while loading the propertyFile "
+ propertyFileName, e);
return null;
}
}
@@ -105,6 +103,7 @@ public final class PropertyLoader
private static void onMissingConfiguration(final String propertyFileName)
{
+ final Logger logger = getLogger();
if (logger.isLoggable(Level.INFO))
{
logger.info("could not find any property files with name " +
propertyFileName);
@@ -120,6 +119,7 @@ public final class PropertyLoader
public static List<Properties> loadAllProperties(String propertyFileName,
Runnable onMissing)
throws IOException
{
+ final Logger logger = getLogger();
ClassLoader cl = WebBeansUtil.getCurrentClassLoader();
Enumeration<URL> propertyUrls = cl.getResources(propertyFileName);
if (propertyUrls == null || !propertyUrls.hasMoreElements())
@@ -200,7 +200,8 @@ public final class PropertyLoader
}
catch(NumberFormatException nfe)
{
- logger.severe(CONFIGURATION_ORDINAL_PROPERTY_NAME + " must be
an integer value!");
+ getLogger()
+ .severe(CONFIGURATION_ORDINAL_PROPERTY_NAME + " must
be an integer value!");
throw nfe;
}
}
@@ -208,6 +209,16 @@ public final class PropertyLoader
return configOrder;
}
+ // we don't care to synchronize here, we just don't want to do it again
and again after some init
+ private static Logger getLogger()
+ {
+ if (logger == null)
+ {
+ logger = WebBeansLoggerFacade.getLogger(PropertyLoader.class);
+ }
+ return logger;
+ }
+
/**
* Merge the given Properties in order of appearance.
* @param sortedProperties