-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
UniqueId.parse fails for methods with array type parameters #810
Comments
Just thought of a 3rd alternative: Escape/unescape forbidden characters. Seems like a valid approach. |
+1 It is still time for breaking changes. Introducing mangling of IDs is something we can do after GA. |
Using a different separator might break another engine's values. Escaping does not have any of those disadvantages. |
Good catch! 👍 We've been generating unique IDs such as |
FYI: I reproduced this error with a test case run by JUnit Jupiter on public class ArrayTests extends AbstractJupiterTestEngineTests {
@Test
void executeTestsForPrimitiveArrayMethodInjectionCases() {
ExecutionEventRecorder eventRecorder = executeTestsForClass(PrimitiveArrayMethodInjectionTestCase.class);
assertEquals(1, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
assertEquals(0, eventRecorder.getTestFailedCount(), "# tests failed");
eventRecorder.getExecutionEvents().stream().map(ExecutionEvent::getTestDescriptor).distinct().skip(2).map(
TestDescriptor::getUniqueId).forEach(id -> {
System.err.println(id);
UniqueId.parse(id.toString());
});
}
@ExtendWith(PrimitiveArrayParameterResolver.class)
private static class PrimitiveArrayMethodInjectionTestCase {
@Test
void primitiveArray(int... ints) {
assertArrayEquals(new int[] { 1, 2, 3 }, ints);
}
}
} The resulting exception is:
|
The most robust solution would be to use a format similar to JSON, where the That should solve all problems, future and present. |
We could also URI encode/decode |
Team decision: Use URI encoding for |
Prior to this commit a type or value string containing a meta-character used by the string representation syntax broke the parsing of an unique id string. Now, the parser uses 3 characters (defaults to `]/[`) to split the segments of the unique id string representation. This improvement does handle a lot more cases than the old implementation, but it can still yield format exceptions when the type or value string contains exactly the 3 characters in order. Fixes #810
in progress by @sormuras |
Prior to this commit segment strings could contain characters that are used by the toString-representation syntax of UniqueIdFormat. Now these "forbidden" (reserved) characters are URL encoded, as well as decoded when parsing unique ids. Fixes #810
Prior to this commit segment strings could contain characters that are used by the toString-representation syntax of UniqueIdFormat. Now these "forbidden" (reserved) characters are URL encoded, as well as decoded when parsing unique ids. Fixes #810
Prior to this commit segment strings could contain characters that are used by the toString-representation syntax of UniqueIdFormat. Now these "forbidden" (reserved) characters are URL encoded, as well as decoded when parsing unique ids. Fixes #810
Prior to this commit segment strings could contain characters that are used by the toString-representation syntax of UniqueIdFormat. Now these "forbidden" (reserved) characters are URL encoded, as well as decoded when parsing unique ids. Fixes #810
Prior to this commit segment strings could contain characters that are used by the toString-representation syntax of UniqueIdFormat. Now these "forbidden" (reserved) characters are URL encoded, as well as decoded when parsing unique ids. Fixes #810
Bug description
will fail with
PreconditionViolation
since array types are described with an[
in front but[
chars are currently forbidden as segment values.Suggested Solution
Change representation of array types in
ReflectionUtils.findMethod(clazz, methodName, parameterTypeNames)
andStringUtils.nullSafeToString(classes)
.Alternative: Don't use
[
as separator char in unique IDs. But some 3rd party tools might already have committed to the current format.Deliverables
segmentType
andvalue
in constructor and decode inparse
.The text was updated successfully, but these errors were encountered: