perwendel / spark

A simple expressive web framework for java. Spark has a kotlin DSL https://github.com/perwendel/spark-kotlin
Apache License 2.0
9.65k stars 1.56k forks source link

Response.cookie throwing java.lang.NullPointerException #656

Closed KnolBee closed 8 years ago

KnolBee commented 8 years ago

Trying to set httponly flag throws exception

Works: response.cookie("jwt","testcookie",86000,true);

Throws exception: response.cookie("jwt","testcookie",86000,true,true);

java.lang.NullPointerException

Maven Entry:

com.sparkjava spark-core 2.5
N0odlez commented 8 years ago

stacktrace? code example?

KnolBee commented 8 years ago

Code:

get("/testcookie",(request, response) -> {
    try {
        response.cookie("jwt", "testcookie", 86000, true, true);
    } catch (Exception exception) {
        exception.printStackTrace();
    }
    return "Hello World";
});

Stack Trace: java.lang.NullPointerException at spark.Response.cookie(Response.java:235) at spark.Response.cookie(Response.java:203) at com.costrategix.microservices.authentication.App.lambda$3(App.java:89) at spark.RouteImpl$1.handle(RouteImpl.java:61) at spark.http.matching.Routes.execute(Routes.java:61) at spark.http.matching.MatcherFilter.doFilter(MatcherFilter.java:126) at spark.embeddedserver.jetty.JettyHandler.doHandle(JettyHandler.java:50) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:189) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119) at org.eclipse.jetty.server.Server.handle(Server.java:517) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95) at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572) at java.lang.Thread.run(Thread.java:745)

tipsy commented 8 years ago

This was fixed in #572