-
-
Notifications
You must be signed in to change notification settings - Fork 807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix flaky #1516
Merged
Merged
Fix flaky #1516
Conversation
This file contains 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 this PR
This PR fixes the error resulting from the flaky test:
net.bytebuddy.implementation.auxiliary.MethodCallProxyTest.testMultipleParameterMethod
.The mentioned tests may fail or pass without changes made to the source code when it is run in different JVMs due to
getDeclaredFields
non-deterministic order.Why the tests fail
MethodCallProxyTest
callsAbstractMethodCallProxyTest
, and there are 2 assertions that fail which usegetDeclaredFields
to assert the field types.getDeclaredFields
method returns the array of fields, and the elements in the returned array are not sorted and are not in any particular order. So, the test fails as the given order can be different from the expected order. This has been the case sinceJava 1.1
version.Reproduce the test failure
Run the tests with NonDex maven plugin. The commands to recreate the flaky test failures are:
mvn -pl cli edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=net.bytebuddy.implementation.auxiliary.MethodCallProxyTest#testMultipleParameterMethod
Fixing the flaky test now may prevent flaky test failures in future Java versions.
Expected results
NonDex
.Actual Result
[INFO] Running net.bytebuddy.implementation.auxiliary.MethodCallProxyTest [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.423 s <<< FAILURE! - in net.bytebuddy.implementation.auxiliary.MethodCallProxyTest [ERROR]testMultipleParameterMethod(net.bytebuddy.implementation.auxiliary.MethodCallProxyTest) Time elapsed: 0.417 s <<< FAILURE! java.lang.AssertionError
Fix
For the first assertion failure, we obtain
proxytarget
from fields then perform an assertion ifproxymethod
is not static.For the second assertion failure, we remove the
proxytarget
class from the fields then sort them. Further, we sort theparameter types
too, then perform assertion of these array lists thus we can ensure that thegetDeclaredFields
order does not cause an assert failure in methodnet.bytebuddy.implementation.auxiliary.MethodCallProxyTest