Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when adding new value to an existing header through StandaloneAhcWSRequest::addHeader #204

Open
hparkerfly opened this issue Dec 13, 2017 · 0 comments

Comments

@hparkerfly
Copy link

hparkerfly commented 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

  1. 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.
  2. This method calls the method StandaloneAhcWSRequest::addValueTo, line 505.
  3. 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

  1. I get UnsupportedOperationException.
  2. 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) 
...
@hparkerfly 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants