File tree 4 files changed +18
-3
lines changed
java-test/src/test/java/retrofit2
4 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 16
16
17
17
** Fixed**
18
18
19
- - Nothing yet!
19
+ - Primitive types used with ` @Tag ` now work by storing the value boxed with the boxed class as the key.
20
20
21
21
22
22
## [ 2.11.0] - 2024-03-28
Original file line number Diff line number Diff line change @@ -3330,6 +3330,19 @@ Call<ResponseBody> method(@Tag String tag) {
3330
3330
assertThat (request .tag (String .class )).isEqualTo ("tagValue" );
3331
3331
}
3332
3332
3333
+ @ Test
3334
+ public void tagPrimitive () {
3335
+ class Example {
3336
+ @ GET ("/" )
3337
+ Call <ResponseBody > method (@ Tag long timestamp ) {
3338
+ return null ;
3339
+ }
3340
+ }
3341
+
3342
+ Request request = buildRequest (Example .class , 42L );
3343
+ assertThat (request .tag (Long .class )).isEqualTo (42L );
3344
+ }
3345
+
3333
3346
@ Test
3334
3347
public void tagGeneric () {
3335
3348
class Example {
Original file line number Diff line number Diff line change @@ -800,7 +800,7 @@ private ParameterHandler<?> parseParameterAnnotation(
800
800
} else if (annotation instanceof Tag ) {
801
801
validateResolvableType (p , type );
802
802
803
- Class <?> tagType = Utils .getRawType (type );
803
+ Class <?> tagType = boxIfPrimitive ( Utils .getRawType (type ) );
804
804
for (int i = p - 1 ; i >= 0 ; i --) {
805
805
ParameterHandler <?> otherHandler = parameterHandlers [i ];
806
806
if (otherHandler instanceof ParameterHandler .Tag
Original file line number Diff line number Diff line change 31
31
* </code></pre>
32
32
*
33
33
* Tag arguments may be {@code null} which will omit them from the request. Passing a parameterized
34
- * type such as {@code List<String>} will use the raw type (i.e., {@code List.class}) as the key.
34
+ * type will use the raw type as the key (e.g., {@code List<String>} uses {@code List.class}).
35
+ * Primitive types will be boxed and stored using the boxed type
36
+ * (e.g., {@code long} uses {@code Long.class}).
35
37
* Duplicate tag types are not allowed.
36
38
*/
37
39
@ Documented
You can’t perform that action at this time.
0 commit comments