[jboss-cvs] JBossAS SVN: r88724 - in projects/bootstrap/trunk: impl-base/src/main/java/org/jboss/bootstrap/impl/base/server and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue May 12 10:39:38 EDT 2009
Author: ALRubinger
Date: 2009-05-12 10:39:37 -0400 (Tue, 12 May 2009)
New Revision: 88724
Modified:
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java
projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/server/AbstractBasicServerInitializer.java
Log:
[JBBOOT-72] Do not set blank/null system properties during server init
Modified: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java 2009-05-12 14:35:54 UTC (rev 88723)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java 2009-05-12 14:39:37 UTC (rev 88724)
@@ -67,7 +67,7 @@
//-------------------------------------------------------------------------------------||
@Before
- public void createAndInitServer() throws Throwable
+ public void createServerAndSetJbossHome() throws Throwable
{
// Create a server that skips real start/stop
this.server = new NoOpJBossASServer(true);
@@ -80,14 +80,6 @@
// to be sure no $JBOSS_HOME default is picked up)
configuration.jbossHome(TestUtils.getJBossHome());
- // Manually set a UDP group and port, as there's no default and we want to test
- final String udpGroupValue = "udpGroup";
- final Integer udpPortValue = 342;
- configuration.udpGroup(udpGroupValue).udpPort(udpPortValue);
-
- // Initialize
- server.initialize();
-
// Log
log.info("Created: " + this.server);
}
@@ -104,22 +96,55 @@
//-------------------------------------------------------------------------------------||
/**
+ * Ensures that the partitioning properties are not initialized,
+ * and return null from {@link System#getProperty(String)}
+ *
+ * JBBOOT-72
+ */
+ @Test
+ public void testClusteringPropertiesUninitialized() throws Throwable
+ {
+ // Log
+ log.info("testClusteringPropertiesUninitialized");
+
+ // Initialize
+ server.initialize();
+
+ // Define property keys
+ final String udpGroupPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_PARTITION_UDP_GROUP;
+ final String udpPortPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_PARTITION_UDP_PORT;
+
+ // Get Properties from System
+ final String udpGroupFromSystem = System.getProperty(udpGroupPropKey);
+ final String udpPortFromSystem = System.getProperty(udpPortPropKey);
+
+ // Ensure null
+ final String failMessage = "Expected non-defaulted property value to be null from system property, was: ";
+ TestCase.assertNull(failMessage + udpGroupFromSystem, udpGroupFromSystem);
+ TestCase.assertNull(failMessage + udpPortFromSystem, udpPortFromSystem);
+ }
+
+ /**
* Ensures that the properties backing the configuration are set
* both on the configuration itself and in the System props. Upon
* cleanup, these properties must be cleared.
*
* @throws Throwable
*/
- /**
- * @throws Throwable
- */
@Test
public void testPropertiesInInitializationLifecycle() throws Throwable
{
-
// Log
log.info("testPropertiesInInitializationLifecycle");
+ // Manually set a UDP group and port, as there's no default and we want to test
+ final String udpGroupValue = "udpGroup";
+ final Integer udpPortValue = 342;
+ server.getConfiguration().udpGroup(udpGroupValue).udpPort(udpPortValue);
+
+ // Initialize
+ server.initialize();
+
// Get an initialized server and config
final JBossASServer server = this.server;
final JBossASServerConfig configuration = server.getConfiguration();
Modified: projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/server/AbstractBasicServerInitializer.java
===================================================================
--- projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/server/AbstractBasicServerInitializer.java 2009-05-12 14:35:54 UTC (rev 88723)
+++ projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/server/AbstractBasicServerInitializer.java 2009-05-12 14:39:37 UTC (rev 88724)
@@ -174,7 +174,8 @@
}
/**
- * Sets the specified system property key to the specified value
+ * Sets the specified system property key to the specified value. If
+ * no value is specified (blank or null) the property will *not* be set.
*
* @param key The non-null key
* @param value
@@ -184,15 +185,18 @@
// Precondition check
assert key != null : "Key for system property was null";
- // Adjust for null
- String valueToSet = value;
- if (valueToSet == null)
+ // Only set non-null values
+ if (value == null || "".equals(value))
{
- valueToSet = "";
+ if (log.isTraceEnabled())
+ {
+ log.trace("Not setting system property for key " + key + " as value was blank or null");
+ }
+ return;
}
// Set
- SecurityActions.setSystemProperty(key, valueToSet);
+ SecurityActions.setSystemProperty(key, value);
// Add to Set
synchronized (this)
@@ -203,8 +207,7 @@
// Log
if (log.isTraceEnabled())
{
- log.trace(("Set system property \"" + key + "\" to: ")
- + (value != null ? "\"" + valueToSet + "\"" : "[EMPTY]"));
+ log.trace(("Set system property \"" + key + "\" to: ") + (value != null ? "\"" + value + "\"" : "[EMPTY]"));
}
}
}
More information about the jboss-cvs-commits
mailing list