diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-08-24 16:56:40 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-09-19 10:34:53 +0200 |
commit | 8677caa79431fd4f9c2fb990c9db742a2157a8f4 (patch) | |
tree | 76a1e25b9bb5ab70346c058119304bf419620891 /sonar-scanner-engine/src/main/java/org/sonar/scanner/config | |
parent | ee9750c2fafc4e1e0f6d8e5e115ae759da4453c4 (diff) | |
download | sonarqube-8677caa79431fd4f9c2fb990c9db742a2157a8f4.tar.gz sonarqube-8677caa79431fd4f9c2fb990c9db742a2157a8f4.zip |
SONAR-9283 Settings, Configuration and Props trim values at insert
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org/sonar/scanner/config')
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/scanner/config/DefaultConfiguration.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/config/DefaultConfiguration.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/config/DefaultConfiguration.java index 3a5e18f2e3f..710b02bbee1 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/config/DefaultConfiguration.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/config/DefaultConfiguration.java @@ -53,16 +53,22 @@ public abstract class DefaultConfiguration implements Configuration { private final PropertyDefinitions definitions; private final Encryption encryption; private final GlobalAnalysisMode mode; - private final Map<String, String> properties = new HashMap<>(); + private final Map<String, String> properties; public DefaultConfiguration(PropertyDefinitions propertyDefinitions, Encryption encryption, GlobalAnalysisMode mode, Map<String, String> props) { this.definitions = requireNonNull(propertyDefinitions); this.encryption = encryption; this.mode = mode; + this.properties = unmodifiableMapWithTrimmedValues(definitions, props); + } + + protected static Map<String, String> unmodifiableMapWithTrimmedValues(PropertyDefinitions definitions, Map<String, String> props) { + Map<String, String> map = new HashMap<>(props.size()); props.forEach((k, v) -> { String validKey = definitions.validKey(k); - properties.put(validKey, trim(v)); + map.put(validKey, trim(v)); }); + return Collections.unmodifiableMap(map); } public GlobalAnalysisMode getMode() { @@ -78,7 +84,7 @@ public abstract class DefaultConfiguration implements Configuration { } public Map<String, String> getProperties() { - return Collections.unmodifiableMap(properties); + return properties; } @Override |