Skip to content

Commit

Permalink
4.x: Remove workaround for Parsson unicode detection issue (helidon-i…
Browse files Browse the repository at this point in the history
  • Loading branch information
Captain1653 authored Nov 7, 2024
1 parent b21ae3c commit bf5e61f
Showing 1 changed file with 1 addition and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.lang.System.Logger.Level;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.charset.UnsupportedCharsetException;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
Expand All @@ -30,7 +27,6 @@
import java.util.Objects;
import java.util.Optional;

import io.helidon.common.NativeImageHelper;
import io.helidon.common.configurable.Resource;

import jakarta.json.Json;
Expand Down Expand Up @@ -59,26 +55,6 @@ public final class JwkKeys {
private final Map<String, Jwk> keyMap = new HashMap<>();
private final List<Jwk> noKeyIdKeys = new LinkedList<>();

private static final boolean AUTOMATIC_CHARSET_DETECTION;

// Workaround for https://github.com/eclipse-ee4j/parsson/issues/121
static {
boolean utf32Available = false;
try {
Charset.forName("UTF-32LE");
Charset.forName("UTF-32BE");
utf32Available = true;
} catch (UnsupportedCharsetException e) {
if (NativeImageHelper.isNativeImage()) {
LOGGER.log(Level.TRACE, "Automatic JSON unicode detection not available."
+ " Add -H:+AddAllCharsets to build your native image with UTF-32 support.", e);
} else {
LOGGER.log(Level.TRACE, "Automatic JSON unicode detection not available.", e);
}
}
AUTOMATIC_CHARSET_DETECTION = utf32Available;
}

private JwkKeys(Builder builder) {
this.keyMap.putAll(builder.keyMap);
this.noKeyIdKeys.addAll(builder.noKeyIdKeys);
Expand Down Expand Up @@ -171,9 +147,7 @@ public Builder addKey(Jwk key) {
public Builder resource(Resource resource) {
Objects.requireNonNull(resource, "Json resource must not be null");
try (InputStream is = resource.stream()) {
JsonObject jsonObject = AUTOMATIC_CHARSET_DETECTION
? JSON.createReader(is).readObject()
: JSON.createReader(is, StandardCharsets.UTF_8).readObject();
JsonObject jsonObject = JSON.createReader(is).readObject();
addKeys(jsonObject);
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to close input stream on resource: " + resource);
Expand Down

0 comments on commit bf5e61f

Please sign in to comment.