diff --git a/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3ObjectMapper.java b/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3ObjectMapper.java index 2b1ed49899b5..b763c9acebd7 100644 --- a/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3ObjectMapper.java +++ b/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3ObjectMapper.java @@ -29,7 +29,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.module.SimpleModule; import java.io.IOException; @@ -54,7 +54,10 @@ static ObjectMapper mapper() { if (!isInitialized) { MAPPER.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - MAPPER.setPropertyNamingStrategy(PropertyNamingStrategies.KebabCaseStrategy.INSTANCE); + // even though using new PropertyNamingStrategy.KebabCaseStrategy() is deprecated + // and PropertyNamingStrategies.KebabCaseStrategy.INSTANCE (introduced in jackson 2.14) is + // recommended, we can't use it because Spark still relies on jackson 2.13.x stuff + MAPPER.setPropertyNamingStrategy(new PropertyNamingStrategy.KebabCaseStrategy()); MAPPER.registerModule(initModule()); isInitialized = true; } @@ -64,7 +67,7 @@ static ObjectMapper mapper() { return MAPPER; } - private static SimpleModule initModule() { + public static SimpleModule initModule() { return new SimpleModule() .addSerializer(ErrorResponse.class, new ErrorResponseSerializer()) .addDeserializer(ErrorResponse.class, new ErrorResponseDeserializer()) diff --git a/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3V4RestSignerClient.java b/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3V4RestSignerClient.java index c0673f1ca48b..f1f53607c98c 100644 --- a/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3V4RestSignerClient.java +++ b/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3V4RestSignerClient.java @@ -99,11 +99,10 @@ public String credential() { return properties().get(OAuth2Properties.CREDENTIAL); } - /** A Bearer token which will be used for interaction with the server. */ - @Nullable - @Value.Lazy - public String token() { - return properties().get(OAuth2Properties.TOKEN); + /** A Bearer token supplier which will be used for interaction with the server. */ + @Value.Default + public Supplier token() { + return () -> properties().get(OAuth2Properties.TOKEN); } private RESTClient httpClient() { @@ -120,19 +119,19 @@ private RESTClient httpClient() { return HTTP_CLIENT_REF.get(); } - @Value.Lazy - AuthSession authSession() { - if (null != token()) { + private AuthSession authSession() { + String token = token().get(); + if (null != token) { return AuthSession.fromAccessToken( httpClient(), TOKEN_REFRESH_EXECUTOR, - token(), + token, expiresAtMillis(properties()), - new AuthSession(ImmutableMap.of(), token(), null, credential(), SCOPE)); + new AuthSession(ImmutableMap.of(), token, null, credential(), SCOPE)); } if (credentialProvided()) { - AuthSession session = new AuthSession(ImmutableMap.of(), token(), null, credential(), SCOPE); + AuthSession session = new AuthSession(ImmutableMap.of(), null, null, credential(), SCOPE); long startTimeMillis = System.currentTimeMillis(); OAuthTokenResponse authResponse = OAuth2Util.fetchToken(httpClient(), session.headers(), credential(), SCOPE);