Skip to content

Commit

Permalink
Use try-with-resource (#322)
Browse files Browse the repository at this point in the history
* Use try-with-resource

* Add missing @nonnull annotation
  • Loading branch information
offa authored Oct 21, 2021
1 parent 623be68 commit c4c6b9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
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

0 comments on commit c4c6b9d

Please sign in to comment.