I updated my Google App Engine app from java 17 to java 21
following instructions on https://cloud.google.com/appengine/docs/standard/java-gen2/upgrade-java-runtime
I am using the legacy bundled services.
It appeared to work fine yesterday, but today all requests fail with this in the logs:
writeError: status=500, message=java.lang.NullPointerException, response=org.eclipse.jetty.ee10.servlet.ServletContextResponse@7abe8062
java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Objects.java:233)
at org.eclipse.jetty.server.CookieCache.parseCookies(CookieCache.java:253)
at org.eclipse.jetty.server.CookieCache.getCookies(CookieCache.java:71)
at org.eclipse.jetty.server.Request.getCookies(Request.java:581)
at org.eclipse.jetty.session.AbstractSessionManager.resolveRequestedSessionId(AbstractSessionManager.java:1231)
at org.eclipse.jetty.ee10.servlet.SessionHandler.handle(SessionHandler.java:690)
at org.eclipse.jetty.server.handler.ContextHandler.handle(ContextHandler.java:851)
at com.google.apphosting.runtime.jetty.ee10.AppEngineWebAppContext.handle(AppEngineWebAppContext.java:301)
at org.eclipse.jetty.server.handler.HotSwapHandler.handle(HotSwapHandler.java:90)
at org.eclipse.jetty.server.Handler$Wrapper.handle(Handler.java:740)
at com.google.apphosting.runtime.jetty.CoreSizeLimitHandler.handle(CoreSizeLimitHandler.java:75)
at org.eclipse.jetty.server.Server.handle(Server.java:181)
at org.eclipse.jetty.server.internal.HttpChannelState$HandlerInvoker.run(HttpChannelState.java:635)
at com.google.apphosting.runtime.jetty.delegate.internal.DelegateConnection.lambda$handle$0(DelegateConnection.java:145)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter$2.run(JettyServletEngineAdapter.java:142)
at com.google.apphosting.runtime.jetty.delegate.internal.DelegateConnection.handle(DelegateConnection.java:141)
at com.google.apphosting.runtime.jetty.delegate.DelegateConnector.service(DelegateConnector.java:49)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:274)
at com.google.apphosting.runtime.RequestRunner.dispatchServletRequest(RequestRunner.java:348)
at com.google.apphosting.runtime.RequestRunner.dispatchRequest(RequestRunner.java:233)
at com.google.apphosting.runtime.RequestRunner.run(RequestRunner.java:199)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:273)
at java.base/java.lang.Thread.run(Thread.java:1583)
There's no direct calls from my codebase in this stacktrace so I'm not sure where to fix it.
I was experiencing the same problem that requests with cookies failed on Java21.
After trying several things forth and back, it suddenly started working, also with my original version.
I had opened a support case with Google, and I asked the support representative if any changes had been made recently on the AppEngine side, and she was able to confirm that:
"During my investigation, I discovered an internal rollout that occurred around August 23rd. These rollouts can take time to propagate through our system. Given the similarities in the behavior described, it's likely that this rollout may have contributed to the resolution of the behavior you reported."
So if you have been experiencing problems with cookies and Java21, just try again now!