Author: aco
Date: Thu Jun 22 20:06:28 2006
New Revision: 416549
URL: http://svn.apache.org/viewvc?rev=416549&view=rev
Log:
- Added null checking during property set to prevent NPE
Modified:
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
Modified:
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
URL:
http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java?rev=416549&r1=416548&r2=416549&view=diff
==============================================================================
---
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
(original)
+++
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
Thu Jun 22 20:06:28 2006
@@ -54,7 +54,7 @@
* Connections. <p/> This class also implements QueueConnectionFactory and
* TopicConnectionFactory. You can use this connection to create both
* QueueConnections and TopicConnections.
- *
+ *
* @version $Revision: 1.9 $
* @see javax.jms.ConnectionFactory
*/
@@ -86,7 +86,7 @@
private boolean useRetroactiveConsumer;
JMSStatsImpl factoryStats = new JMSStatsImpl();
-
+
static protected final Executor DEFAULT_CONNECTION_EXECUTOR = new
ScheduledThreadPoolExecutor(5, new ThreadFactory() {
public Thread newThread(Runnable run) {
Thread thread = new Thread(run);
@@ -120,7 +120,7 @@
throw new RuntimeException("This should never happen: " + e, e);
}
}
-
+
/**
* @param brokerURL
* @return
@@ -237,7 +237,7 @@
connection.setOptimizeAcknowledge(isOptimizeAcknowledge());
connection.setUseRetroactiveConsumer(isUseRetroactiveConsumer());
connection.setRedeliveryPolicy(getRedeliveryPolicy());
-
+
transport.start();
if( clientID !=null )
@@ -269,23 +269,23 @@
}
public void setBrokerURL(String brokerURL) {
this.brokerURL = createURI(brokerURL);
-
+
// Use all the properties prefixed with 'jms.' to set the connection
factory
// options.
if( this.brokerURL.getQuery() !=null ) {
// It might be a standard URI or...
try {
-
+
Map map = URISupport.parseQuery(this.brokerURL.getQuery());
if( IntrospectionSupport.setProperties(this, map, "jms.") ) {
this.brokerURL =
URISupport.createRemainingURI(this.brokerURL, map);
}
-
+
} catch (URISyntaxException e) {
}
-
+
} else {
-
+
// It might be a composite URI.
try {
CompositeData data = URISupport.parseComposite(this.brokerURL);
@@ -360,7 +360,7 @@
public void setUserName(String userName) {
this.userName = userName;
}
-
+
public boolean isUseRetroactiveConsumer() {
return useRetroactiveConsumer;
}
@@ -386,13 +386,13 @@
}
public void buildFromProperties(Properties properties) {
-
+
if (properties == null) {
properties = new Properties();
}
-
+
IntrospectionSupport.setProperties(this, properties);
-
+
String temp = properties.getProperty(Context.PROVIDER_URL);
if (temp == null || temp.length() == 0) {
temp = properties.getProperty("brokerURL");
@@ -404,23 +404,37 @@
public void populateProperties(Properties props) {
props.setProperty("asyncDispatch",
Boolean.toString(isAsyncDispatch()));
- props.setProperty(Context.PROVIDER_URL, getBrokerURL());
- props.setProperty("brokerURL", getBrokerURL());
- if (getClientID() != null)
+
+ if (getBrokerURL() != null) {
+ props.setProperty(Context.PROVIDER_URL, getBrokerURL());
+ props.setProperty("brokerURL", getBrokerURL());
+ }
+
+ if (getClientID() != null) {
props.setProperty("clientID", getClientID());
+ }
+
props.setProperty("copyMessageOnSend",
Boolean.toString(isCopyMessageOnSend()));
props.setProperty("disableTimeStampsByDefault",
Boolean.toString(isDisableTimeStampsByDefault()));
props.setProperty("objectMessageSerializationDefered",
Boolean.toString(isObjectMessageSerializationDefered()));
props.setProperty("optimizedMessageDispatch",
Boolean.toString(isOptimizedMessageDispatch()));
- props.setProperty("password", getPassword());
+
+ if (getPassword() != null) {
+ props.setProperty("password", getPassword());
+ }
+
props.setProperty("useAsyncSend", Boolean.toString(isUseAsyncSend()));
props.setProperty("useCompression",
Boolean.toString(isUseCompression()));
props.setProperty("useRetroactiveConsumer",
Boolean.toString(isUseRetroactiveConsumer()));
- props.setProperty("userName", getUserName());
+
+ if (getUserName() != null) {
+ props.setProperty("userName", getUserName());
+ }
+
props.setProperty("closeTimeout", Integer.toString(getCloseTimeout()));
props.setProperty("alwaysSessionAsync",
Boolean.toString(isAlwaysSessionAsync()));
props.setProperty("optimizeAcknowledge",
Boolean.toString(isOptimizeAcknowledge()));
-
+
}
public boolean isUseCompression() {