Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
java.util.List contains null if query param doesn't specified fix #1806
- Loading branch information
Showing
7 changed files
with
97 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package tests.i1806; | ||
|
||
import io.jooby.annotations.GET; | ||
import io.jooby.annotations.QueryParam; | ||
|
||
import java.util.List; | ||
|
||
public class C1806 { | ||
@GET("/1806/c") | ||
public List<String> sayHi(@QueryParam List<String> names) { | ||
return names; | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
modules/jooby-apt/src/test/java/tests/i1806/Issue1806.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package tests.i1806; | ||
|
||
import io.jooby.MockRouter; | ||
import io.jooby.apt.MvcModuleCompilerRunner; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Collections; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class Issue1806 { | ||
|
||
@Test | ||
public void shouldNotGetListWithNullValue() throws Exception { | ||
new MvcModuleCompilerRunner(new C1806()) | ||
.debugModule(app -> { | ||
MockRouter router = new MockRouter(app); | ||
assertEquals(Collections.emptyList(), router.get("/1806/c").value()); | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.jooby.i1806; | ||
|
||
import io.jooby.annotations.GET; | ||
import io.jooby.annotations.QueryParam; | ||
|
||
import java.util.List; | ||
|
||
public class C1806 { | ||
@GET("/1806/c") | ||
public List<String> sayHi(@QueryParam List<String> names) { | ||
return names; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.jooby.i1806; | ||
|
||
import io.jooby.junit.ServerTest; | ||
import io.jooby.junit.ServerTestRunner; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class Issue1806 { | ||
@ServerTest | ||
public void shouldNotGetListWithNullValue(ServerTestRunner runner) { | ||
runner.define(app -> { | ||
app.mvc(new C1806()); | ||
app.get("/1806/s", ctx -> ctx.query("names").toList(String.class)); | ||
}).ready(client -> { | ||
client.get("/1806/s", rsp -> { | ||
assertEquals("[]", rsp.body().string()); | ||
}); | ||
client.get("/1806/c", rsp -> { | ||
assertEquals("[]", rsp.body().string()); | ||
}); | ||
}); | ||
} | ||
} |