-
-
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 test in DescriptionGenericBuilderTest
by sorting for deterministic iterations
#1547
Conversation
I am curious: is this the only test that suffers from this assumption? Or is it just a random pick? I would consider that there are many places this is assumed, as Byte Buddy often parses members and returns them in the declaration order, too, just as the reflection API. |
Since I picked this test from Flaky Test Dataset, I am unsure whether other tests suffer from the assumption. I have started testing the other tests too. Please give me a few days to update about them. |
I see. Could you somehow investigate if there sre more such ordering issues? If so, I'd rsther fix them in one go or do not fix them at all. |
…and MethodCallProxyTest#testNonGenericParameter
@raphw , I detected a few more tests that could fail because of the ordering issue. 1. ClassFileVersionOtherTest#testLatestVersion
2. MethodCallProxyTest#testNonGenericParameter
3. TypeDescriptionArrayProjectionTest#testTypeAnnotationExceptionType
|
The following tests also fail because of flakiness, but I would like to have some more discussion on them. Issue Details
Test failuresThe following tests fail because of the above mentioned issue:
Possible Fix
Issue Details Continuation
Possible Fix
Questions
|
Looking through this, I am not sure if I will follow this up. At some places, Byte Buddy's parser is supposed to work as the JVM parser, so it's not quite random that the order is like that. I would like to keep them aligned and in this light, for now, I can rely on the member order, also if this is property is not guaranteed. |
Before closing this PR, I would like to confirm if you had visited my above comment, explaining the issues with tests
Even the Javadoc of Class.getFields() and Class.getDeclaredFields() confirms that the order WILL not be maintained. If needed, please let me know so that I could update the PR to fix only those tests. The issue and fix are similar to #1516 |
Thanks, reconsidering, I can merge these changes. The "latest version" test was however broken as the version field was not updated. I fixed this myself now. Can you change the PR to exclude that change? |
@raphw, Thanks for the reconsideration. Do you want me to remove the fixes for |
This PR fixes 1 flaky test failure in module
byte-buddy-dep
1. Test that could fail
byte-buddy-dep
net.bytebuddy.description.type.TypeDescriptionGenericBuilderTest
testTypeAnnotationExceptionType
2. Why the test might fail?
The mentioned test tests the exception types of
TypeAnnotationSamples.foo:35
, which are of typeGeneric
andRuntimeException
. But, it assumes the exception types to be in the declared order, ie.Generic
followed byRuntimeException
.byte-buddy/byte-buddy-dep/src/test/java-8/net/bytebuddy/test/precompiled/v8/TypeAnnotationSamples.java
Lines 35 to 36 in 880027c
The exception types are returned by
Method.getGenericExceptionTypes
atTypeDescriptionGenericBuilderTest.java:43
, but there is no official documentation that mentions this order will be same as the declared order.byte-buddy/byte-buddy-dep/src/test/java/net/bytebuddy/description/type/TypeDescriptionGenericBuilderTest.java
Line 43 in 880027c
Since there is no guarantee in order of exception types returned, the order might change, resulting in the test failure.
3. How to reproduce?
Expected Result
NonDex
.Actual Result
NonDex
produced the following result4. How I fixed?
Method.getGenericExceptionTypes
remain consistent across different runs by sorting the array based on the type name.mvn test -pl byte-buddy-dep
, and all the tests passed.