You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by yh...@apache.org on 2024/01/09 16:04:00 UTC
(beam) branch master updated: remove threadlocal for DESERIALIZATION_CONTEXT and use copy instead (#29952)
This is an automated email from the ASF dual-hosted git repository.
yhu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new 97ca4430d97 remove threadlocal for DESERIALIZATION_CONTEXT and use copy instead (#29952)
97ca4430d97 is described below
commit 97ca4430d97b782a3b95fc56805d51f4ebd19377
Author: Jerry Wang <jr...@gmail.com>
AuthorDate: Wed Jan 10 00:03:50 2024 +0800
remove threadlocal for DESERIALIZATION_CONTEXT and use copy instead (#29952)
Co-authored-by: jierwang <ji...@ebay.com>
---
.../beam/sdk/options/PipelineOptionsFactory.java | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java
index 555f50bc823..0b0ef88cf65 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java
@@ -500,15 +500,12 @@ public class PipelineOptionsFactory {
new ObjectMapper()
.registerModules(ObjectMapper.findModules(ReflectHelpers.findClassLoader()));
- private static final ThreadLocal<DefaultDeserializationContext> DESERIALIZATION_CONTEXT =
- ThreadLocal.withInitial(
- () ->
- new DefaultDeserializationContext.Impl(
- MAPPER.getDeserializationContext().getFactory())
- .createInstance(
- MAPPER.getDeserializationConfig(),
- new TokenBuffer(MAPPER, false).asParser(),
- new InjectableValues.Std()));
+ private static final DefaultDeserializationContext DESERIALIZATION_CONTEXT =
+ new DefaultDeserializationContext.Impl(MAPPER.getDeserializationContext().getFactory())
+ .createInstance(
+ MAPPER.getDeserializationConfig(),
+ new TokenBuffer(MAPPER, false).asParser(),
+ new InjectableValues.Std());
static final DefaultSerializerProvider SERIALIZER_PROVIDER =
new DefaultSerializerProvider.Impl()
@@ -1731,7 +1728,7 @@ public class PipelineOptionsFactory {
BeanProperty prop = createBeanProperty(method);
AnnotatedMember annotatedMethod = prop.getMember();
- DefaultDeserializationContext context = DESERIALIZATION_CONTEXT.get();
+ DefaultDeserializationContext context = DESERIALIZATION_CONTEXT.copy();
Object maybeDeserializerClass =
context.getAnnotationIntrospector().findDeserializer(annotatedMethod);
@@ -1803,7 +1800,7 @@ public class PipelineOptionsFactory {
parser.nextToken();
JsonDeserializer<Object> jsonDeserializer = getDeserializerForMethod(method);
- return jsonDeserializer.deserialize(parser, DESERIALIZATION_CONTEXT.get());
+ return jsonDeserializer.deserialize(parser, DESERIALIZATION_CONTEXT.copy());
}
/**