Skip to content

Commit

Permalink
Findbugs
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarolobato committed Aug 11, 2016
1 parent 9d46446 commit 7d384e1
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials;
import com.google.inject.Inject;

import antlr.Utils;
import hudson.AbortException;
import hudson.EnvVars;
import hudson.FilePath;
Expand All @@ -69,6 +70,7 @@
import hudson.model.AbstractBuild;
import hudson.model.Computer;
import hudson.model.JDK;
import hudson.model.Node;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.slaves.WorkspaceList;
Expand Down Expand Up @@ -179,7 +181,11 @@ private void setupJDK() throws AbortException, IOException, InterruptedException
if (jdk == null) {
throw new AbortException("Could not find the JDK: " + step.getJdk() + ". Make sure it is configured on the Global Tool Configuration page");
}
jdk = jdk.forNode(getComputer().getNode(), listener).forEnvironment(env);
Node node = getComputer().getNode();
if (node == null){
throw new AbortException("Could not obtain the Node for the computer: " + getComputer().getName());
}
jdk = jdk.forNode(node, listener).forEnvironment(env);
jdk.buildEnvVars(envOverride);
} else { // see #detectWithContainer()
LOGGER.log(Level.FINE, "Ignoring JDK Installation parameter: {0}", step.getJdk());
Expand Down Expand Up @@ -257,7 +263,12 @@ private String obtainMavenExec() throws AbortException, IOException, Interrupted

if (mi != null) {
console.println("Using Maven Installation " + mi.getName());
mi = mi.forNode(getComputer().getNode(), listener).forEnvironment(env);

Node node = getComputer().getNode();
if (node == null){
throw new AbortException("Could not obtain the Node for the computer: " + getComputer().getName());
}
mi = mi.forNode(node, listener).forEnvironment(env);
mi.buildEnvVars(envOverride);
mvnExecPath = mi.getExecutable(launcher);
} else {
Expand Down Expand Up @@ -297,7 +308,7 @@ private String obtainMavenExec() throws AbortException, IOException, Interrupted
// if at this point mvnExecPath is still null try to use which/where command to find a maven executable
if (mvnExecPath == null) {
LOGGER.fine("No Maven Installation or MAVEN_HOME found, looking for mvn executable by using which/where command");
if (getComputer().isUnix()) {
if (Boolean.TRUE.equals(getComputer().isUnix())) {
mvnExecPath = readFromProcess("/bin/sh", "-c", "which mvn");
} else {
mvnExecPath = readFromProcess("where", "mvn.cmd");
Expand Down Expand Up @@ -353,7 +364,7 @@ private String mavenWrapperContent(FilePath mvnExec, String settingsFile, String

ArgumentListBuilder argList = new ArgumentListBuilder(mvnExec.getRemote());

boolean isUnix = getComputer().isUnix();
boolean isUnix = Boolean.TRUE.equals(getComputer().isUnix());

String lineSep = isUnix ? "\n" : "\r\n";

Expand Down

0 comments on commit 7d384e1

Please sign in to comment.