Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close the stream properly to avoid lock when using jenkins ui and git scriptler repo #35

Merged
merged 1 commit into from
Sep 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import hudson.model.Computer;
import hudson.util.StreamTaskListener;

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
Expand Down Expand Up @@ -70,9 +72,9 @@ public class ScriptHelper {
}
Script s = ScriptlerConfiguration.getConfiguration().getScriptById(id);
if (withSrc && s != null) {
try {
File scriptSrc = new File(ScriptlerManagement.getScriptDirectory(), s.getScriptPath());
Reader reader = new InputStreamReader(new FileInputStream(scriptSrc), Charset.forName("UTF-8"));
File scriptSrc = new File(ScriptlerManagement.getScriptDirectory(), s.getScriptPath());
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(scriptSrc),
Charset.forName("UTF-8")))) {
String src = IOUtils.toString(reader);
s.setScript(src);
} catch (IOException e) {
Expand Down