Fixes NPE in ClientCookieDecoder
Motivation: NPE in `ClientCookieDecoder` if cookie starts with comma. Modifications: Check `cookieBuilder` for `null` in the return. Result: No fails NPE on invalid cookies.
This commit is contained in:
parent
c58069f284
commit
587afddb27
@ -140,7 +140,7 @@ public final class ClientCookieDecoder extends CookieDecoder {
|
||||
cookieBuilder.appendAttribute(nameBegin, nameEnd, valueBegin, valueEnd);
|
||||
}
|
||||
}
|
||||
return cookieBuilder.cookie();
|
||||
return cookieBuilder != null ? cookieBuilder.cookie() : null;
|
||||
}
|
||||
|
||||
private static class CookieBuilder {
|
||||
|
@ -203,6 +203,13 @@ public class ClientCookieDecoderTest {
|
||||
assertNull(cookie);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecodingInvalidValuesWithCommaAtStart() {
|
||||
assertNull(ClientCookieDecoder.STRICT.decode(","));
|
||||
assertNull(ClientCookieDecoder.STRICT.decode(",a"));
|
||||
assertNull(ClientCookieDecoder.STRICT.decode(",a=a"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecodingLongValue() {
|
||||
String longValue =
|
||||
|
Loading…
Reference in New Issue
Block a user