Repository navigation
Fix datanode PowerMock tests failing when user_encrypt_token is set - #19008
Merged
JackieTien97 merged 1 commit intoOct 24, 2026
Merged
Conversation
When the user_encrypt_token environment variable is set, TSFileDescriptor derives the TsFile encryption key with javax.crypto.Mac while it initializes. PowerMock does not defer javax.crypto to the system class loader, so inside a PowerMock test Mac is defined by PowerMock's class loader in an unnamed module, and its static initializer fails because java.base does not export sun.security.util. 12 of the 14 PowerMock test classes in datanode then fail, on JDK 17 and JDK 21 alike. Add a PowerMock global ignore for javax.crypto.* to the datanode test resources so that these classes always come from the JDK.
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.
Description
When the
user_encrypt_tokenenvironment variable is set (the TsFile encryption token, seeIoTDBStartCheck), 12 of the 14 PowerMock test classes iniotdb-core/datanodefail, on JDK 17 andJDK 21 alike:
The rest of each class then fails with
NoClassDefFoundError: Could not initialize class org.apache.tsfile.utils.FSUtils(orIoTDBDescriptor$IoTDBDescriptorHolder).TSFileDescriptorderives the TsFile encryption key fromuser_encrypt_tokenwithjavax.crypto.Macwhile it initializes. PowerMock 2.0.9 defers onlyjava.*,javax.accessibility.*,sun.*and a few test packages to the system class loader, so inside aPowerMock test
javax.crypto.Macis defined by PowerMock'sMockClassLoaderin an unnamed module,and its static initializer cannot access
java.baseinternals. CI does not set the variable, so itis not affected, but anyone who keeps the variable in their shell (for example to work on TsFile
encryption) cannot run these tests locally.
Changes
Add
iotdb-core/datanode/src/test/resources/org/powermock/extensions/configuration.propertieswithpowermock.global-ignore=javax.crypto.*. PowerMock merges this global list with each class's@PowerMockIgnore, so every PowerMock test in the module (including future ones) loadsjavax.cryptofrom the JDK. No test mocksjavax.crypto.Verification
All 14 PowerMock test classes in
iotdb-core/datanode, run withmvn test -pl iotdb-core/datanode -am -Dtest=<the 14 classes>:user_encrypt_tokensetuser_encrypt_tokensetThe RAT license check passes for the new file.
🤖 Generated with Claude Code