summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Eidsness2013-08-28 16:39:51 (EDT)
committerAndrew Gvozdev2013-08-28 17:23:23 (EDT)
commit5dbcc8ec2193beb29b99dee558e02322ca0ce6ff (patch)
tree6793f978bc8a0d28429bdb6a5a59b4ebfda3fa50
parentaf5a14ac6d1512d8174de907019d58f99c00a536 (diff)
downloadorg.eclipse.cdt-5dbcc8ec2193beb29b99dee558e02322ca0ce6ff.zip
org.eclipse.cdt-5dbcc8ec2193beb29b99dee558e02322ca0ce6ff.tar.gz
org.eclipse.cdt-5dbcc8ec2193beb29b99dee558e02322ca0ce6ff.tar.bz2
Bug 415789: NPE in ScannerConfigBuilderrefs/changes/20/15820/4
An implementation of IEnvironmentVariable is returning null for its key or value. The javadoc on this interface doesn't mention null, which I guess makes it a valid value. This patch checks the result before trying to put it into an instance of java.util.Properties. Change-Id: Ic04ddd72dfb558ca403b549b64847c3437971407 Signed-off-by: Andrew Eidsness <andrewe@jfront.com> Reviewed-on: https://git.eclipse.org/r/15820 Reviewed-by: Andrew Gvozdev <angvoz.dev@gmail.com> IP-Clean: Andrew Gvozdev <angvoz.dev@gmail.com> Tested-by: Andrew Gvozdev <angvoz.dev@gmail.com>
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/ScannerConfigBuilder.java9
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IConfigurationEnvironmentVariableSupplier.java2
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariableManager.java5
3 files changed, 11 insertions, 5 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/ScannerConfigBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/ScannerConfigBuilder.java
index 78099db..4def274 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/ScannerConfigBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/ScannerConfigBuilder.java
@@ -171,8 +171,13 @@ public class ScannerConfigBuilder extends ACBuilder {
ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(cfg);
IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager();
IEnvironmentVariable[] vars = mngr.getVariables(cfgDes, true);
- for(int i = 0; i < vars.length; i++){
- envProps.setProperty(vars[i].getName(), vars[i].getValue());
+
+ for(int i = 0; i < vars.length; i++) {
+ if (vars[i] != null
+ && vars[i].getName() != null) {
+ String value = vars[i].getValue();
+ envProps.setProperty(vars[i].getName(), value == null ? "" : value);
+ }
}
return envProps;
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IConfigurationEnvironmentVariableSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IConfigurationEnvironmentVariableSupplier.java
index 2ad8545..a6c5760 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IConfigurationEnvironmentVariableSupplier.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IConfigurationEnvironmentVariableSupplier.java
@@ -50,7 +50,7 @@ public interface IConfigurationEnvironmentVariableSupplier {
* and the provider in turn calls that supplier again. Also the supplier should not know anything
* about the environment variables defined for the higher levels.
* @return The array of IBuildEnvironmentVariable that represents the environment variables.
- * If the array contains any {@code null} it will be ignored.
+ * The array may contain {@code null} values.
*/
IBuildEnvironmentVariable[] getVariables(IConfiguration configuration, IEnvironmentVariableProvider provider);
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariableManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariableManager.java
index 70f0d71..7daabca 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariableManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/envvar/IEnvironmentVariableManager.java
@@ -29,7 +29,7 @@ public interface IEnvironmentVariableManager{
*
*
* @return the reference to the IBuildEnvironmentVariable interface representing
- * the variable of a given name
+ * the variable of a given name or null
* @param name environment variable name
* if environment variable names are case insensitive in the current OS,
* the environment variable provider will query the getVariable method of suppliers always
@@ -52,7 +52,8 @@ public interface IEnvironmentVariableManager{
* the environment variable provider will remove the duplicates of the variables if their names
* differ only by case
*
- * @return the array of IBuildEnvironmentVariable that represents the environment variables
+ * @return the array of IBuildEnvironmentVariable that represents the environment variables (the
+ * array may contain null values)
*/
public IEnvironmentVariable[] getVariables(ICConfigurationDescription cfg, boolean resolveMacros);