From e89bd9e214e3b25fdfda4e0204d84b927c244cdd Mon Sep 17 00:00:00 2001 From: Ilayaperumal Gopinathan Date: Mon, 8 Jun 2015 17:37:18 -0700 Subject: [PATCH] Handle `null` values for moduleDefaults - If the moduleDefaults have `null` values then skip. Otherwise, the `EnvironmentDecryptApplicationInitializer` breaks --- .gitignore | 2 ++ .../ModuleOptionsPropertySourceInitializer.java | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 166699fb5..701903f73 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,8 @@ _site/ .DS_Store *.sw* *.iml +*.ipr +*.iws .idea .factorypath spring-xd-samples/*/xd diff --git a/spring-xd-runner/src/main/java/org/springframework/bus/xd/bootstrap/ModuleOptionsPropertySourceInitializer.java b/spring-xd-runner/src/main/java/org/springframework/bus/xd/bootstrap/ModuleOptionsPropertySourceInitializer.java index 28ffe3f53..5e304f190 100644 --- a/spring-xd-runner/src/main/java/org/springframework/bus/xd/bootstrap/ModuleOptionsPropertySourceInitializer.java +++ b/spring-xd-runner/src/main/java/org/springframework/bus/xd/bootstrap/ModuleOptionsPropertySourceInitializer.java @@ -48,7 +48,7 @@ import org.springframework.xd.module.options.ModuleOptionsMetadataResolver; /** * Initialize the application context with default values for the module options. - * + * * @author Dave Syer * */ @@ -60,7 +60,7 @@ public class ModuleOptionsPropertySourceInitializer implements @Autowired private MessageBusProperties module = new MessageBusProperties(); - + @Autowired(required=false) private EnvironmentAwareModuleOptionsMetadataResolver wrapper; @@ -71,7 +71,9 @@ public class ModuleOptionsPropertySourceInitializer implements ModuleOptionsMetadata resolved = resolver.resolve(getModuleDefinition()); Map map = new LinkedHashMap(); for (ModuleOption option : resolved) { - map.put(option.getName(), option.getDefaultValue()); + if (option.getDefaultValue() != null) { + map.put(option.getName(), option.getDefaultValue()); + } } insert(environment, new MapPropertySource("moduleDefaults", map)); } @@ -105,7 +107,7 @@ public class ModuleOptionsPropertySourceInitializer implements public DefaultModuleOptionsMetadataResolver defaultResolver() { return new DefaultModuleOptionsMetadataResolver(); } - + @ConditionalOnExpression("'${xd.module.config.location:${xd.config.home:}}'!=''") protected static class EnvironmentAwareModuleOptionsMetadataResolverConfiguration { @Bean