Skip to content

Commit

Permalink
try with closed resources
Browse files Browse the repository at this point in the history
  • Loading branch information
EyalDelarea committed Sep 12, 2024
1 parent cea9c45 commit 9ec102a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/io/jenkins/plugins/jfrog/JfStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private void configAllServers(Launcher.ProcStarter launcher, Job<?, ?> job) thro
}
}

private void addConfigArguments(ArgumentListBuilder builder, JFrogPlatformInstance jfrogPlatformInstance, String jfrogBinaryPath, Job<?, ?> job, Launcher.ProcStarter launcher) {
private void addConfigArguments(ArgumentListBuilder builder, JFrogPlatformInstance jfrogPlatformInstance, String jfrogBinaryPath, Job<?, ?> job, Launcher.ProcStarter launcher) throws IOException {
String credentialsId = jfrogPlatformInstance.getCredentialsConfig().getCredentialsId();
builder.add(jfrogBinaryPath).add("c").add("add").add(jfrogPlatformInstance.getId());
// Add credentials
Expand All @@ -230,8 +230,9 @@ private void addConfigArguments(ArgumentListBuilder builder, JFrogPlatformInstan
// Use password-stdin if available
if (this.currentCliVersion.isAtLeast(MIN_CLI_VERSION_PASSWORD_STDIN)) {
builder.add("--password-stdin");
ByteArrayInputStream inputStream = new ByteArrayInputStream(credentials.getPassword().getPlainText().getBytes(StandardCharsets.UTF_8));
launcher.stdin(inputStream);
try(ByteArrayInputStream inputStream = new ByteArrayInputStream(credentials.getPassword().getPlainText().getBytes(StandardCharsets.UTF_8))) {
launcher.stdin(inputStream);
}
} else {
builder.addMasked("--password=" + credentials.getPassword());
}
Expand Down

0 comments on commit 9ec102a

Please sign in to comment.