Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMykola Nikishov2015-10-11 06:06:51 -0400
committerMykola Nikishov2015-10-19 16:42:16 -0400
commit78844f9e5fd4b51fb1e43bd0317b7cb2e9d38d58 (patch)
tree931864af964b6ca907ba22c46b91173224a4120b
parent8449f44a59706525f0c275dca3d1cdb420202ba0 (diff)
downloadrt.equinox.p2-78844f9e5fd4b51fb1e43bd0317b7cb2e9d38d58.tar.gz
rt.equinox.p2-78844f9e5fd4b51fb1e43bd0317b7cb2e9d38d58.tar.xz
rt.equinox.p2-78844f9e5fd4b51fb1e43bd0317b7cb2e9d38d58.zip
Prevent NPE in DebugHelper's formatParameters methodI20151110-0800
Change-Id: I816a68305ec086da8bfd9b7ec179ece6af35b52e Signed-off-by: Mykola Nikishov <mn@mn.com.ua>
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DebugHelper.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/AllTests.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DebugHelperTest.java29
3 files changed, 33 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DebugHelper.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DebugHelper.java
index 58c9fdbac..98b2ee0b0 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DebugHelper.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DebugHelper.java
@@ -160,7 +160,9 @@ public class DebugHelper {
buffer.append(key);
buffer.append('=');
Object value = e.getValue();
- if (value instanceof String || value instanceof File || value instanceof Operand || value instanceof IArtifactKey || value instanceof IInstallableUnit)
+ if (value == null)
+ buffer.append(value);
+ else if (value instanceof String || value instanceof File || value instanceof Operand || value instanceof IArtifactKey || value instanceof IInstallableUnit)
buffer.append(value);
else if (value instanceof IProfile)
buffer.append(((IProfile) value).getProfileId());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/AllTests.java
index 1248def6c..15abb9363 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/AllTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/AllTests.java
@@ -40,6 +40,7 @@ public class AllTests extends TestCase {
suite.addTestSuite(VariableTest.class);
suite.addTestSuite(VariableTest2.class);
suite.addTestSuite(VariableTest3.class);
+ suite.addTestSuite(DebugHelperTest.class);
return suite;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DebugHelperTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DebugHelperTest.java
new file mode 100644
index 000000000..c6f9133c7
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DebugHelperTest.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2015 Mykola Nikishov.
+ * 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:
+ * Mykola Nikishov - initial implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.engine;
+
+import java.util.HashMap;
+import junit.framework.TestCase;
+import org.eclipse.equinox.internal.p2.engine.DebugHelper;
+import org.junit.Assert;
+
+public class DebugHelperTest extends TestCase {
+
+ public void testFormatParametersContainsNullValue() {
+ HashMap<String, Object> parameters = new HashMap<String, Object>();
+ parameters.put("key", null);
+
+ String result = DebugHelper.formatParameters(parameters);
+
+ Assert.assertEquals("{key=null}", result);
+ }
+
+}

Back to the top