Skip to content
Permalink
Browse files

[JENKINS-27363] - Annotate sensibleVariables (may be null)

Patch to the core: jenkinsci/jenkins#1601

Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>
  • Loading branch information
oleg-nenashev committed Mar 11, 2015
1 parent 0033cdf commit d70408a03fce3875d516e95054146ed273611f99
Showing with 11 additions and 6 deletions.
  1. +11 −6 src/main/java/org/jenkinsci/lib/envinject/EnvInjectAction.java
@@ -13,6 +13,7 @@
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import javax.annotation.CheckForNull;

/**
* @author Gregory Boissinot
@@ -21,7 +22,7 @@

public static final String URL_NAME = "injectedEnvVars";

protected transient Map<String, String> envMap;
protected transient @CheckForNull Map<String, String> envMap;

private AbstractBuild build;

@@ -30,9 +31,10 @@
*/
private transient Map<String, String> resultVariables;
private transient File rootDir;
private transient Set<String> sensibleVariables;
private transient @CheckForNull Set<String> sensibleVariables;

public EnvInjectAction(AbstractBuild build, Map<String, String> envMap) {
public EnvInjectAction(AbstractBuild build,
@CheckForNull Map<String, String> envMap) {
this.build = build;
this.envMap = envMap;
}
@@ -41,7 +43,9 @@ public void overrideAll(Map<String, String> all) {
overrideAll(Collections.<String>emptySet(), all);
}

public void overrideAll(final Set<String> sensibleVariables, Map<String, String> all) {
public void overrideAll(
final @CheckForNull Set<String> sensibleVariables,
@CheckForNull Map<String, String> all) {
if (envMap == null) {
return;
}
@@ -91,7 +95,8 @@ private Object writeReplace() throws ObjectStreamException {
dao.saveEnvironment(build.getRootDir(), Maps.transformEntries(envMap,
new Maps.EntryTransformer<String, String, String>() {
public String transformEntry(String key, String value) {
return sensibleVariables.contains(key) ? "********" : value;
return (sensibleVariables != null && sensibleVariables.contains(key))
? "********" : value;
}
}));
return this;
@@ -155,7 +160,7 @@ public Object getTarget() {
throw new UnsupportedOperationException();
}

public Set<String> getSensibleVariables() {
public @CheckForNull Set<String> getSensibleVariables() {
return sensibleVariables;
}
}

0 comments on commit d70408a

Please sign in to comment.
You can’t perform that action at this time.