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
Ubuntu 16.04 LTS
Linux 4.4.0-101-generic #124-Ubuntu SMP Fri Nov 10 18:29:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
JDK
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
Library Dependencies
javaWs
Expected Behavior
I'm using StandaloneAhcWSRequest to add a new value for an existing header to a given request. I call the method StandaloneAhcWSRequest::addHeader, line 100 in StandaloneAhcWSRequest.class.
This method calls the method StandaloneAhcWSRequest::addValueTo, line 505.
Then it manages the Map<String, List<String>> headers. If the new header already existed, it takes the list and adds the new value to it. Therefore, if for example we have the header myHeader already existing in headers map with a value1 and we want to add a value2 to that header, in the end it should have: <"myHeader", ["value1", "value2"]>
Actual Behavior
I get UnsupportedOperationException.
The reason is that the implementation used for the list which is going to get the new element added is the scala one. In scala the list is immutable.
Stack trace
...
play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.scala:56)
... 6 common frames omitted
Caused by: java.lang.UnsupportedOperationException: null
at java.util.AbstractList.add(AbstractList.java:148)
at java.util.AbstractList.add(AbstractList.java:108)
at play.libs.ws.ahc.StandaloneAhcWSRequest.addValueTo(StandaloneAhcWSRequest.java:508)
at play.libs.ws.ahc.StandaloneAhcWSRequest.addHeader(StandaloneAhcWSRequest.java:101)
at play.libs.ws.ahc.StandaloneAhcWSRequest.addHeader(StandaloneAhcWSRequest.java:41)
...
The text was updated successfully, but these errors were encountered:
hparkerfly
changed the title
Exception when adding new value to an existing header through StandaloneAhcWSRequest::addHeader()
Exception when adding new value to an existing header through StandaloneAhcWSRequest::addHeader
Dec 13, 2017
Play Version
2.6.6
API
Java
Operating System
Ubuntu 16.04 LTS
Linux 4.4.0-101-generic #124-Ubuntu SMP Fri Nov 10 18:29:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
JDK
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
Library Dependencies
javaWs
Expected Behavior
StandaloneAhcWSRequest
to add a new value for an existing header to a given request. I call the methodStandaloneAhcWSRequest::addHeader
, line 100 inStandaloneAhcWSRequest.class
.StandaloneAhcWSRequest::addValueTo
, line 505.Map<String, List<String>> headers
. If the new header already existed, it takes the list and adds the new value to it. Therefore, if for example we have the headermyHeader
already existing in headers map with avalue1
and we want to add avalue2
to that header, in the end it should have:<"myHeader", ["value1", "value2"]>
Actual Behavior
UnsupportedOperationException
.Stack trace
The text was updated successfully, but these errors were encountered: