Skip to content

Commit 13a5fe8

Browse files
committed
Jooby 1.6.x throws exception for empty cookies jooby-project#1331
1 parent a106081 commit 13a5fe8

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

jooby/src/main/java/org/jooby/internal/RequestImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ public Map<String, Mutant> headers() {
436436
public Mutant cookie(final String name) {
437437
List<String> values = req.cookies().stream().filter(c -> c.name().equalsIgnoreCase(name))
438438
.findFirst()
439-
.map(cookie -> ImmutableList.of(cookie.value().get()))
439+
.map(cookie -> ImmutableList.of(cookie.value().orElse("")))
440440
.orElse(ImmutableList.of());
441441

442442
return new MutantImpl(require(ParserExecutor.class),
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.jooby.issues;
2+
3+
import org.jooby.test.ServerFeature;
4+
import org.junit.Test;
5+
6+
public class Issue1331 extends ServerFeature {
7+
8+
{
9+
get("/1331", req -> {
10+
return req.cookie("login").value("not set");
11+
});
12+
}
13+
14+
@Test
15+
public void shouldNotFailOnEmptyCookies() throws Exception {
16+
request()
17+
.get("/1331")
18+
.header("Cookie", "login=;Version=1;Path=/1331")
19+
.expect("");
20+
request()
21+
.get("/1331")
22+
.expect("not set");
23+
}
24+
25+
}

0 commit comments

Comments
 (0)