From b6b1e0a0adda605f7a62c915d1aef606b961e36f Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Sat, 2 Jul 2022 09:36:56 +0200 Subject: [PATCH] Fix DefaultCharset bug pattern flagged by error prone See more details in: [1]. [1] https://errorprone.info/bugpattern/DefaultCharset Change-Id: Ib6aa279f9dcf63dff0672df5b5be3ea72597b1d8 --- .../src/org/eclipse/jgit/transport/AwsRequestSignerV4.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AwsRequestSignerV4.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AwsRequestSignerV4.java index ab3013762..cf4420fe5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AwsRequestSignerV4.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AwsRequestSignerV4.java @@ -10,6 +10,8 @@ package org.eclipse.jgit.transport; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; @@ -145,7 +147,7 @@ public static void sign(HttpURLConnection httpURLConnection, canonicalRequest.getBytes(StandardCharsets.UTF_8))); // compute the signing key - byte[] secretKey = (SCHEME + new String(awsSecretKey)).getBytes(); + byte[] secretKey = (SCHEME + new String(awsSecretKey)).getBytes(UTF_8); byte[] dateKey = signStringWithKey(scopeDate, secretKey); byte[] regionKey = signStringWithKey(regionName, dateKey); byte[] serviceKey = signStringWithKey(serviceName, regionKey);