You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my app I construct a WSRequest and call .stream() on it (this is the Scala API). It's talking to an in-house service, which responds with a Set-Cookie header with a cookie name but no cookie value. In my repro setup I use a mock response with a line saying Set-Cookie: absent-value;. In both cases I get a null pointer exception.
Since the cookie value is absent, the underlying cookie builder returns null
Then Some(c) = Some(null) acts just like c = null (in the cookie builder)
Then asCookie(null) is called, which tries to access (null).name which throws the null pointer exception.
I believe Some(c) = Option(<the same expression as before>) will make the null pointer exception not happen, but it's not obvious to me that this is the right design.
It's just what I did as a workaround: I made a wrapper around WSRepsonse which forwards everything to the underlying response, except it diverts the code path leading to this buggy line onto a copy-pasted-and-the-fixed version which says Option instead of Some on this line—plus some incidental and (I believe) unrelated changes.
I'm not sure what behavior to expect, given that value-free cookie headers do not conform to any HTTP standard I could find—not that I looked all day—but I definitely don't expect a null pointer exception.
Here's sbt dependencyTree | grep ws | grep -v aws | cut -f2- -d'-' | sort -u, just in case it helps. My above links are to the most recent version of each of the linked files, as far as I can find out; they look like differently indented versions of the source my LSP/metals setup jumps to.
In my app I construct a
WSRequest
and call.stream()
on it (this is the Scala API). It's talking to an in-house service, which responds with aSet-Cookie
header with a cookie name but no cookie value. In my repro setup I use a mock response with a line sayingSet-Cookie: absent-value;
. In both cases I get a null pointer exception.I tracked it down:
play-ws/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/StreamedResponse.scala
Line 56 in d06f8b1
play-ws/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/CookieBuilder.scala
Line 21 in d06f8b1
Some(c) = Some(null)
acts just likec = null
(in the cookie builder)asCookie(null)
is called, which tries to access(null).name
which throws the null pointer exception.I believe
Some(c) = Option(<the same expression as before>)
will make the null pointer exception not happen, but it's not obvious to me that this is the right design.It's just what I did as a workaround: I made a wrapper around WSRepsonse which forwards everything to the underlying response, except it diverts the code path leading to this buggy line onto a copy-pasted-and-the-fixed version which says
Option
instead ofSome
on this line—plus some incidental and (I believe) unrelated changes.I'm not sure what behavior to expect, given that value-free cookie headers do not conform to any HTTP standard I could find—not that I looked all day—but I definitely don't expect a null pointer exception.
Here's
sbt dependencyTree | grep ws | grep -v aws | cut -f2- -d'-' | sort -u
, just in case it helps. My above links are to the most recent version of each of the linked files, as far as I can find out; they look like differently indented versions of the source my LSP/metals setup jumps to.API: Scala. We also have a bit of java stuff lying around but I don't think it interacts with this bug.
OS/Java:
The text was updated successfully, but these errors were encountered: