-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
UriTemplate expansion is inconsistent when using beans to pass the values #11192
Comments
That class is replaced by |
I did not get this memo 😀 . Now that you mention it @dstepanov, I believe this intention should be properly documented (a mention in the Guide and the |
Well, the class package io.micronaut.http.uri;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
class UriTemplateMatcherTest {
@ParameterizedTest
@CsvSource(delimiter = '|', value = {
"{+id*}|one=alpha,two=bravo",
"{#id*}|#one=alpha,two=bravo",
"{#id*}|#one=alpha,two=bravo",
"{;id*}|;one=alpha;two=bravo",
"{&id*}|&one=alpha&two=bravo",
})
void testDeepObjectParam(String template, String expected) {
UriTemplateMatcher templateMatcher = new UriTemplateMatcher(template);
DeepObject deepObject = new DeepObject("alpha", "bravo");
String expansion = templateMatcher.expand(Map.of("id", deepObject));
assertEquals(expected, expansion);
}
} |
I didn't deprecate it because it's used in the routes API, and there is no way to use the new one—the idea is to replace one with another in v5. |
@dstepanov, @yawkat Are there any plans to fix this bug? |
Discussed in #11191
Originally posted by nedelva September 18, 2024
I was playing with UriTemplate and I wrote a JUnit 5 test to check if it implements all of the features shown in URI.js.
In the test
testDeepObjectParam
I am using a record defined as:The test using
DeepObject
is only mimicking thetestDeepObjectMapParam
but using arecord
instead of aMap
. The funny thing is it fails only a few cases but not always the same lines (in my runs, lines 1, 3, 5 or just 3 and 4 from theCsvSource
).The failure always is about the order of evaluation of the values in the expansion:
I also noticed that if the test method
testDeepObjectParam
is copied as the sole test in another test class, different cases fail (!)(Perhaps some race condition is occurring?)
Shouldn't this expansion produce predictable results? (Not that it matters for the expanded URI)
Final note: the HashMap is evaluated in the same way, but this is a happy case. If I use
Map.of("one","alpha","two","bravo")
the testtestDeepObjectMapParam
will start failing as well a few cases.The text was updated successfully, but these errors were encountered: