[FLINK-39951][python] Fix string reference equality bug in ArrayConstructor causing silent long value truncation#28473
Open
jubins wants to merge 1 commit into
Conversation
…ructor causing silent long value truncation
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
Fixes FLINK-39951 —
ArrayConstructor.construct()uses reference equality (==) to compare the pickle typecode string"l"instead of value equality (.equals()). Sinceargs[0]is a deserializedStringobject at runtime and not an interned literal, the==comparison always returnsfalse, making thelong[]code path effectively dead code.As a result, any Python array with typecode
'l'(64-bit longs) silently falls through tosuper.construct(), which treats the values asint[]and truncates them to 32 bits. Users passing long values larger thanInteger.MAX_VALUEreceive silently corrupted data with no error or warning.The fix replaces
args[0] == "l"with"l".equals(args[0])on line 30 ofArrayConstructor.java.Brief change log
ArrayConstructor.construct()to use"l".equals(args[0])instead ofargs[0] == "l"for typecode comparisonArrayConstructorTestwith four test cases covering: large long values aboveInteger.MAX_VALUE, single value arrays, empty arrays, and delegation to the parent class for non-'l'typecodesVerifying this change
This change is covered by new unit tests in
ArrayConstructorTest:testLongArrayPreservesValuesAboveIntMax()— the core regression test; usesnew String("l")to guarantee a non-interned reference (proving the old==would have failed), then asserts that values like3_000_000_000LandLong.MAX_VALUEare preserved correctly aslong[]testLongArrayWithSingleValue()— verifies a single large long value is handled correctlytestLongArrayWithEmptyList()— verifies empty input produces an emptylong[]testNonLongTypecodesDelegateToSuper()— confirms other typecodes (e.g.'i') still fall through to the parentsuper.construct()correctlyDoes this pull request potentially affect one of the following parts
@Public(Evolving): noDocumentation
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Opus 4.8