Skip to content

Commit

Permalink
Closing resource
Browse files Browse the repository at this point in the history
  • Loading branch information
janario committed Mar 31, 2015
1 parent 606128d commit 8ed4b8b
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions src/main/java/jenkins/plugins/http_request/HttpRequest.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
package jenkins.plugins.http_request;

import static com.google.common.base.Preconditions.checkArgument;

import javax.servlet.ServletException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import com.google.common.base.Objects;
import com.google.common.base.Strings;
import com.google.common.base.Supplier;
import com.google.common.collect.Range;
import com.google.common.collect.Ranges;
import com.google.common.primitives.Ints;
import hudson.*;
import hudson.EnvVars;
import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.Util;
import hudson.init.InitMilestone;
import hudson.init.Initializer;
import hudson.model.AbstractBuild;
Expand Down Expand Up @@ -36,18 +53,6 @@
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;

import javax.servlet.ServletException;
import java.io.IOException;
import java.io.PrintStream;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import static com.google.common.base.Preconditions.checkArgument;

/**
* @author Janario Oliveira
*/
Expand Down Expand Up @@ -244,7 +249,15 @@ private void logResponse(AbstractBuild<?, ?> build, PrintStream logger, Response
logger.println("Response: \n" + responseContentSupplier.get());
}
if (outputFilePath != null && responseContentSupplier.get() != null) {
outputFilePath.write().write(responseContentSupplier.get().getBytes());
OutputStream write = null;
try {
write = outputFilePath.write();
write.write(responseContentSupplier.get().getBytes());
} finally {
if (write != null) {
write.close();
}
}
}
}
}
Expand Down

0 comments on commit 8ed4b8b

Please sign in to comment.