-
Notifications
You must be signed in to change notification settings - Fork 3.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
Empty query parameter leads to collection of null #3435
Comments
@dsvensson Thanks for reporting this! What you describe is the default behavior of Jersey 2.x. Example (no Dropwizard-specific classes whatsoever): import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.Test;
import javax.ws.rs.*;
import javax.ws.rs.core.*;
import java.util.List;
import java.util.UUID;
import static org.junit.Assert.assertEquals;
public class Issue3435 extends JerseyTest {
@Override
protected Application configure() {
return new ResourceConfig(TestResource.class);
}
@Test
public void emptyStringQueryParamReturnsListWithOneNullElement() {
Response response = target("test")
.queryParam("list", "")
.request()
.get();
assertEquals(200, response.getStatus());
assertEquals("1: [null]", response.readEntity(String.class));
}
@Test
public void missingQueryParamReturnsEmptyList() {
Response response = target("test")
.request()
.get();
assertEquals(200, response.getStatus());
assertEquals("0: []", response.readEntity(String.class));
}
@Test
public void filledQueryParamReturnsListWithOneElement() {
Response response = target("test")
.queryParam("list", "ec0cf621-d744-4a1c-b1d8-4b8a44b3dad7")
.request()
.get();
assertEquals(200, response.getStatus());
assertEquals("1: [ec0cf621-d744-4a1c-b1d8-4b8a44b3dad7]", response.readEntity(String.class));
}
@Path("test")
public static class TestResource {
@GET
public String test(@QueryParam("list") List<UUID> list) {
return list.size() + ": " + list.toString();
}
}
} A similar issue has been filed for Jersey in eclipse-ee4j/jersey#563, but it looks like the behavior has changed again. Would you mind filing an issue at https://github.com/eclipse-ee4j/jersey/issues to sort this out? |
github-actions
bot
added
the
stale
Stale issue or pull request which will be closed soon
label
Nov 26, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Consider the following endpoint:
When issuing
curl http://localhost/liststuff?id=
.. that is,id
without a value. TheSet<UUID> ids
will be a set that contains onenull
item.I've tried adding
@NotEmpty Set<UUID>
, andSet<@NotNull UUID>
and various permutations, without getting the endpoint to reject the request.Is this a known limitation or am I missing something?
The text was updated successfully, but these errors were encountered: