Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schreiber2015-06-30 07:57:15 -0400
committerGerrit Code Review @ Eclipse.org2015-07-16 10:45:35 -0400
commit3aa5d09ef179ad83311824169892674c683ed781 (patch)
tree4f20cd406a9022420d0b7db44451b62a90a63a7a
parente5b4bb6d446e8daf35329b72c960bb0cc4496754 (diff)
downloadorg.eclipse.tycho-3aa5d09ef179ad83311824169892674c683ed781.tar.gz
org.eclipse.tycho-3aa5d09ef179ad83311824169892674c683ed781.tar.xz
org.eclipse.tycho-3aa5d09ef179ad83311824169892674c683ed781.zip
Bug 470621: Using empty string environment variable values instead of
null When configuring empty environment variables (tycho-surefire and tycho-extra eclipserun plugins): <environmentVariables> <test></test> </environmentVariables> the environmentVariables map had null values which ended up in a NPE during launch. Now, when environment variables get added to the EquinoxLaunchConfiguration, null values are replaced with empty strings Bug: 470621 Change-Id: I2bf6e9b7ce7ceabd12fc66fbc3583e5c9133fa0f Signed-off-by: Martin Schreiber <martin.schreiber@bachmann.info>
-rw-r--r--sisu-equinox/sisu-equinox-launching/src/main/java/org/eclipse/sisu/equinox/launching/internal/EquinoxLaunchConfiguration.java7
-rw-r--r--sisu-equinox/sisu-equinox-launching/src/test/java/org/eclipse/sisu/equinox/launching/internal/EquinoxLaunchConfigurationTest.java37
2 files changed, 42 insertions, 2 deletions
diff --git a/sisu-equinox/sisu-equinox-launching/src/main/java/org/eclipse/sisu/equinox/launching/internal/EquinoxLaunchConfiguration.java b/sisu-equinox/sisu-equinox-launching/src/main/java/org/eclipse/sisu/equinox/launching/internal/EquinoxLaunchConfiguration.java
index eb9480530..b54ecfc9c 100644
--- a/sisu-equinox/sisu-equinox-launching/src/main/java/org/eclipse/sisu/equinox/launching/internal/EquinoxLaunchConfiguration.java
+++ b/sisu-equinox/sisu-equinox-launching/src/main/java/org/eclipse/sisu/equinox/launching/internal/EquinoxLaunchConfiguration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Sonatype Inc. and others.
+ * Copyright (c) 2008, 2015 Sonatype Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -38,7 +38,10 @@ public class EquinoxLaunchConfiguration implements LaunchConfiguration {
}
public void addEnvironmentVariables(Map<String, String> variables) {
- env.putAll(variables);
+ for (String key : variables.keySet()) {
+ String value = variables.get(key);
+ env.put(key, (value != null) ? value : "");
+ }
}
@Override
diff --git a/sisu-equinox/sisu-equinox-launching/src/test/java/org/eclipse/sisu/equinox/launching/internal/EquinoxLaunchConfigurationTest.java b/sisu-equinox/sisu-equinox-launching/src/test/java/org/eclipse/sisu/equinox/launching/internal/EquinoxLaunchConfigurationTest.java
new file mode 100644
index 000000000..a0272dbc7
--- /dev/null
+++ b/sisu-equinox/sisu-equinox-launching/src/test/java/org/eclipse/sisu/equinox/launching/internal/EquinoxLaunchConfigurationTest.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Bachmann electronic GmbH and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bachmann electronic GmbH - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.sisu.equinox.launching.internal;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+public class EquinoxLaunchConfigurationTest {
+
+ @Test
+ public void testAddEnvironmentVariables() {
+ EquinoxLaunchConfiguration config = new EquinoxLaunchConfiguration(null);
+ Map<String, String> envVariables = new HashMap<String, String>();
+ envVariables.put("key1", "value1");
+ envVariables.put("key2", null);
+ config.addEnvironmentVariables(envVariables);
+
+ Map<String, String> environment = config.getEnvironment();
+ assertThat(environment.size(), equalTo(2));
+ assertThat(environment.get("key1"), equalTo("value1"));
+ assertThat(environment.get("key2"), equalTo(""));
+ }
+
+}

Back to the top