Skip to content
This repository was archived by the owner on Jul 31, 2022. It is now read-only.

Commit 4dec125

Browse files
authored
Merge pull request #27 from Ktt-Development/cookie-illegalArgs
Added NullPointerException on missing Cookie key and value
2 parents df839de + 7e7a05e commit 4dec125

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/com/kttdevelopment/simplehttpserver/SimpleHttpCookie.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,14 @@ public class SimpleHttpCookie {
4343
* @author Ktt Development
4444
*/
4545
public SimpleHttpCookie(final String name, final String value, final String domain, final String path, final String sameSite, final Date expires, final Integer maxAge, final boolean secure, final boolean httpOnly){
46-
this.name = name;
47-
this.value = value;
46+
if(name == null)
47+
throw new NullPointerException("Cookie name can not be null");
48+
else
49+
this.name = name;
50+
if(value == null)
51+
throw new NullPointerException("Cookie value can not be null");
52+
else
53+
this.value = value;
4854
this.domain = domain;
4955
this.path = path;
5056
this.sameSite = sameSite;

0 commit comments

Comments
 (0)