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

Use try-with-resource #322

Merged
merged 2 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
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 @@ -44,24 +44,14 @@ public JellyScriptContent() {
}

@Override
public String evaluate(@NonNull Run<?, ?> run, FilePath workspace, @NonNull TaskListener listener, String macroName) throws MacroEvaluationException, IOException, InterruptedException {
InputStream inputStream = null;

try {
inputStream = getFileInputStream(run, workspace, template, JELLY_EXTENSION);
public String evaluate(@NonNull Run<?, ?> run, FilePath workspace, @NonNull TaskListener listener, String macroName)
throws MacroEvaluationException, IOException, InterruptedException {
try (InputStream inputStream = getFileInputStream(run, workspace, template, JELLY_EXTENSION)) {
return renderContent(run, inputStream, listener);
} catch (JellyException e) {
return "JellyException: " + e.getMessage();
} catch (FileNotFoundException e) {
return generateMissingFile("Jelly", template);
} finally {
try {
if (inputStream != null) {
inputStream.close();
}
} catch (IOException e) {
// ignore
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public UserProperty newInstance(User user) {

@NonNull
@Override
public UserProperty newInstance(StaplerRequest req, JSONObject json) throws FormException {
public UserProperty newInstance(StaplerRequest req, @NonNull JSONObject json) throws FormException {
List<EmailTrigger> triggers = req != null ? req.bindJSONToList(EmailTrigger.class, json) : Collections.emptyList();
return new UserProperty(triggers);
}
Expand Down