Skip to content

Commit 272d704

Browse files
glasstigerclaude
andcommitted
Fix Java 8 build: use URLEncoder String charset
The follow-up that pre-encodes the OIDC form params changed urlEncode() to URLEncoder.encode(value, StandardCharsets.UTF_8). That Charset overload is @SInCE 10, so the source-of-truth JDK 8 build fails to compile: "incompatible types: Charset cannot be converted to String" at OidcDeviceAuth.java:896. Revert urlEncode() to the Java 8 String-charset form, URLEncoder.encode(value, "UTF-8") with the UnsupportedEncodingException catch, and drop the now-unused StandardCharsets import. The constructor-time pre-encoding of clientId/scope/audience/device_code is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 8d38d4f commit 272d704

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

core/src/main/java/io/questdb/client/cutlass/auth/OidcDeviceAuth.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
import io.questdb.client.std.str.DirectUtf8Sequence;
4646
import io.questdb.client.std.str.StringSink;
4747

48+
import java.io.UnsupportedEncodingException;
4849
import java.net.URLEncoder;
49-
import java.nio.charset.StandardCharsets;
5050
import java.util.concurrent.locks.ReentrantLock;
5151

5252
/**
@@ -892,8 +892,13 @@ private static boolean settingsChannelIsPlaintext(Endpoint server) {
892892
}
893893

894894
private static String urlEncode(String value) {
895-
// the Charset overload is Java 10; the client targets Java 8, so use the String-charset form
896-
return URLEncoder.encode(value, StandardCharsets.UTF_8);
895+
try {
896+
// the Charset overload is Java 10; the client targets Java 8, so use the String-charset form
897+
return URLEncoder.encode(value, "UTF-8");
898+
} catch (UnsupportedEncodingException e) {
899+
// UTF-8 is guaranteed present on every JVM, so this is unreachable; rethrow defensively
900+
throw new OidcAuthException(e).put("UTF-8 encoding is not supported");
901+
}
897902
}
898903

899904
private static void validateEndpointOrigins(Endpoint tokenEndpoint, Endpoint deviceAuthorizationEndpoint, Endpoint issuer) {

0 commit comments

Comments
 (0)