dev@glassfish.java.net

AMXConfigProxyTests (in QL) versus GrizzlyConfigSchemaMigrator

From: Bobby Bissett <bobby.bissett_at_oracle.com>
Date: Mon, 24 Jan 2011 14:29:11 -0500

Hi all,

In the QL tests, a config called AMXConfigProxyTests.TEST is created that has a null HttpService object. The getHttpService object is marked @Element(required=true) but not @NotNull. So I think it's valid for null to be returned there, but wanted to check: is this what we expect?

The null HttpService object is causing a failure in a necessary fix for upgrade code (because the admin console calls some upgrade code during runtime to handle 3.0.X servers). This is the issue: http://java.net/jira/browse/GLASSFISH-15599

I can fix it with this change (wrapping the 3 lines in an "if not null" check), along with the actual change for the bug, but it's a little odd to make a change to suit a test (and not the other way around):

Index: admin/config-api/src/main/java/org/glassfish/config/support/GrizzlyConfigSchemaMigrator.java
===================================================================
--- admin/config-api/src/main/java/org/glassfish/config/support/GrizzlyConfigSchemaMigrator.java (revision 44679)
+++ admin/config-api/src/main/java/org/glassfish/config/support/GrizzlyConfigSchemaMigrator.java (working copy)
@@ -80,6 +80,7 @@
 import org.jvnet.hk2.annotations.Service;
 import org.jvnet.hk2.component.Habitat;
 import org.jvnet.hk2.component.PostConstruct;
+import org.jvnet.hk2.config.ConfigBeanProxy;
 import org.jvnet.hk2.config.ConfigSupport;
 import org.jvnet.hk2.config.SingleConfigCode;
 import org.jvnet.hk2.config.TransactionFailure;
@@ -108,9 +109,19 @@
                     createFromScratch();
                 }
                 normalizeThreadPools();
- processHttpListeners();
- promoteHttpServiceProperties(currentConfig.getHttpService());
- promoteVirtualServerProperties(currentConfig.getHttpService());
+ if (currentConfig.getHttpService() != null) {
+ processHttpListeners();
+ promoteHttpServiceProperties(
+ currentConfig.getHttpService());
+ promoteVirtualServerProperties(
+ currentConfig.getHttpService());
+ } else {
+ // this only happens during some unit tests
+ Logger.getAnonymousLogger().log(Level.WARNING,
+ String.format(
+ "config.getHttpService() null for config '%s'",
+ currentConfig.getName()));
+ }
                 promoteSystemProperties();
                 addAsadminProtocol(currentConfig.getNetworkConfig());
             } catch (TransactionFailure tf) {

Anyone have a problem with making GrizzlyConfigSchemaMigrator a bit more defensive in order to fix GLASSFISH-15599?

Thanks,
Bobby