summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Wall <kwall@apache.org>2015-02-07 19:09:18 +0000
committerKeith Wall <kwall@apache.org>2015-02-07 19:09:18 +0000
commitbd9ca7255cd5c08ec348dd5976249e0a8dd1a8bc (patch)
treec2ee1e45fcfd309b0fd45783627085209fc2d3ba
parent13bd5eee9f73678f500ac717673b67ac0740f6ee (diff)
downloadqpid-python-bd9ca7255cd5c08ec348dd5976249e0a8dd1a8bc.tar.gz
QPID-6371: [Java Broker/Java Common] Prevent log4j warning during Broker startup
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1658098 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java6
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java76
2 files changed, 19 insertions, 63 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
index df55080f67..6c37462011 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
@@ -66,6 +66,7 @@ import org.apache.qpid.client.failover.FailoverProtectedOperation;
import org.apache.qpid.client.protocol.AMQProtocolHandler;
import org.apache.qpid.client.security.CallbackHandlerRegistry;
import org.apache.qpid.client.state.AMQStateManager;
+import org.apache.qpid.common.QpidProperties;
import org.apache.qpid.configuration.ClientProperties;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.framing.AMQShortString;
@@ -195,6 +196,11 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect
static
{
+ if (_logger.isDebugEnabled())
+ {
+ _logger.debug("Qpid version : " + QpidProperties.getVersionString());
+ }
+
// The registering of any additional SASL mechanisms with the Java Security API requires
// SecurityManager permissions. In execution environments such as web containers,
// this may require adjustments to the Java security.policy.
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java
index 74219f216e..d077cc9717 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java
@@ -22,12 +22,8 @@ package org.apache.qpid.common;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Map;
import java.util.Properties;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* QpidProperties captures the project name, version number, and source code repository revision number from a properties
* file which is generated as part of the build process. Normally, the name and version number are pulled from the module
@@ -37,18 +33,9 @@ import org.slf4j.LoggerFactory;
*
* <p>To get the build version of any Qpid code call the {@link #main} method. This version string is usually also
* printed to the console on broker start up.
- * <p>
- * TODO Code to locate/load/log properties can be factored into a reusable properties utils class. Avoid having this
- * same snippet of loading code scattered in many places.
- * <p>
- * TODO Could also add a build number property for a sequential build number assigned by an automated build system, for
- * build reproducability purposes.
*/
public class QpidProperties
{
- /** Used for debugging purposes. */
- private static final Logger _logger = LoggerFactory.getLogger(QpidProperties.class);
-
/** The name of the version properties file to load from the class path. */
public static final String VERSION_RESOURCE = "qpidversion.properties";
@@ -68,13 +55,13 @@ public class QpidProperties
private static final String DEFAULT = "unknown";
/** Holds the product name. */
- private static String productName = DEFAULT;
+ private static final String productName;
/** Holds the product version. */
- private static String releaseVersion = DEFAULT;
+ private static final String releaseVersion;
/** Holds the source code revision. */
- private static String buildVersion = DEFAULT;
+ private static final String buildVersion;
private static final Properties properties = new Properties();
@@ -82,40 +69,24 @@ public class QpidProperties
static
{
- try
+ try(InputStream propertyStream = QpidProperties.class.getClassLoader().getResourceAsStream(VERSION_RESOURCE))
{
- InputStream propertyStream = QpidProperties.class.getClassLoader().getResourceAsStream(VERSION_RESOURCE);
- if (propertyStream == null)
- {
- _logger.warn("Unable to find resource " + VERSION_RESOURCE + " from classloader");
- }
- else
+ if (propertyStream != null)
{
properties.load(propertyStream);
-
- if (_logger.isDebugEnabled())
- {
- _logger.debug("Dumping QpidProperties");
- for (Map.Entry<Object, Object> entry : properties.entrySet())
- {
- _logger.debug("Property: " + entry.getKey() + " Value: " + entry.getValue());
- }
-
- _logger.debug("End of property dump");
- }
-
- productName = readPropertyValue(properties, PRODUCT_NAME_PROPERTY);
- String versionSuffix = (String) properties.get(RELEASE_VERSION_SUFFIX);
- String version = readPropertyValue(properties, RELEASE_VERSION_PROPERTY);
- releaseVersion = versionSuffix == null || "".equals(versionSuffix) ? version : version + ";" + versionSuffix;
- buildVersion = readPropertyValue(properties, BUILD_VERSION_PROPERTY);
}
}
catch (IOException e)
{
- // Log a warning about this and leave the values initialized to unknown.
- _logger.error("Could not load version.properties resource: " + e, e);
+ // Ignore, most likely running within an IDE, values will have the DEFAULT text
}
+
+ String versionSuffix = properties.getProperty(RELEASE_VERSION_SUFFIX);
+ String version = properties.getProperty(RELEASE_VERSION_PROPERTY, DEFAULT);
+
+ productName = properties.getProperty(PRODUCT_NAME_PROPERTY, DEFAULT);
+ releaseVersion = versionSuffix == null || "".equals(versionSuffix) ? version : version + ";" + versionSuffix;
+ buildVersion = properties.getProperty(BUILD_VERSION_PROPERTY, DEFAULT);
}
public static Properties asProperties()
@@ -164,27 +135,6 @@ public class QpidProperties
}
/**
- * Helper method to extract a named property from properties.
- *
- * @param props The properties.
- * @param propertyName The named property to extract.
- *
- * @return The extracted property or a default value if the properties do not contain the named property.
- *
- * @todo A bit pointless.
- */
- private static String readPropertyValue(Properties props, String propertyName)
- {
- String retVal = (String) props.get(propertyName);
- if (retVal == null)
- {
- retVal = DEFAULT;
- }
-
- return retVal;
- }
-
- /**
* Prints the versioning information to the console. This is extremely usefull for identifying Qpid code in the
* wild, where the origination of the code has been forgotten.
*