tzulitai commented on a change in pull request #8570: [FLINK-12688] [state]
Make serializer lazy initialization thread safe in StateDescriptor
URL: https://github.com/apache/flink/pull/8570#discussion_r289263588
##########
File path:
flink-core/src/main/java/org/apache/flink/api/common/state/StateDescriptor.java
##########
@@ -82,8 +88,8 @@
/** The serializer for the type. May be eagerly initialized in the
constructor,
* or lazily once the {@link
#initializeSerializerUnlessSet(ExecutionConfig)} method
* is called. */
- @Nullable
- protected TypeSerializer<T> serializer;
+ @VisibleForTesting
+ protected final AtomicReference<TypeSerializer<T>>
serializerAtomicReference = new AtomicReference<>();
Review comment:
It's still a bit dangerous to make this `protected`, IMO. We can't guarantee
subclasses would not mess around with this.
If we want to make this visible for testing, a separate package-private
final method for getting the original wrapped serializer is better.
WDYT?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services