Skip to content

Commit

Permalink
use UTF_8 when converting error response (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
jetersen authored Aug 28, 2019
1 parent 63f634a commit e576658
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ unclassified:
hashicorpVault:
configuration:
vaultCredentialId: "vaultToken"
vaultUrl: "${CASC_VAULT_AGENT_ADDR:-http://localhost:8100}" # Vault Agent Addr
vaultUrl: "https://vault.company.io"

credentials:
system:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import hudson.security.ACL;
import hudson.tasks.BuildWrapperDescriptor;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -183,14 +184,13 @@ private void parseVaultErrorCodes(String path, LogicalResponse response) {
}
} else if (status >= 400) {
String errors = Optional
.of(Json.parse(new String(restResponse.getBody()))).map(JsonValue::asObject)
.of(Json.parse(new String(restResponse.getBody(), StandardCharsets.UTF_8))).map(JsonValue::asObject)
.map(j -> j.get("errors")).map(JsonValue::asArray).map(JsonArray::values)
.map(j -> j.stream().map(JsonValue::asString).collect(Collectors.joining("\n")))
.orElse("");
logger.printf("Vault responded with %d error code.%n", status);
if (StringUtils.isNotBlank(errors)) {
logger.printf("Vault responded with errors: %s%n",
new String(restResponse.getBody()));
logger.printf("Vault responded with errors: %s%n", errors);
}
}
}
Expand Down

0 comments on commit e576658

Please sign in to comment.