aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/src/main/java/com/yahoo/application/Application.java5
-rw-r--r--container-dev/pom.xml4
-rw-r--r--jdisc_http_service/src/main/java/com/yahoo/jdisc/http/HttpRequest.java20
-rw-r--r--jdisc_http_service/src/test/java/com/yahoo/jdisc/http/HttpRequestTestCase.java36
-rw-r--r--pom.xml5
5 files changed, 28 insertions, 42 deletions
diff --git a/application/src/main/java/com/yahoo/application/Application.java b/application/src/main/java/com/yahoo/application/Application.java
index cfcce72487b..5b91c8ff89c 100644
--- a/application/src/main/java/com/yahoo/application/Application.java
+++ b/application/src/main/java/com/yahoo/application/Application.java
@@ -20,7 +20,6 @@ import com.yahoo.search.rendering.Renderer;
import com.yahoo.text.StringUtilities;
import com.yahoo.text.Utf8;
import com.yahoo.vespa.model.VespaModel;
-import org.jboss.netty.channel.ChannelException;
import org.xml.sax.SAXException;
import java.io.File;
@@ -316,7 +315,7 @@ public final class Application implements AutoCloseable {
break;
} catch (Error e) { // the container thinks this is really serious, in this case is it not in the cause is a BindException
// catch bind error and reset container
- if (e.getCause() != null && e.getCause() instanceof ChannelException && e.getCause().getCause() != null && e.getCause().getCause() instanceof BindException) {
+ if (e.getCause() != null && e.getCause().getCause() != null && e.getCause().getCause() instanceof BindException) {
exception = (Exception) e.getCause().getCause();
com.yahoo.container.Container.resetInstance(); // this is needed to be able to recreate the container from config again
} else {
@@ -667,4 +666,4 @@ public final class Application implements AutoCloseable {
}
}
}
-} \ No newline at end of file
+}
diff --git a/container-dev/pom.xml b/container-dev/pom.xml
index c180780faf9..6d1833319dc 100644
--- a/container-dev/pom.xml
+++ b/container-dev/pom.xml
@@ -57,6 +57,10 @@
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ </dependency>
+ <dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<classifier>no_aop</classifier>
diff --git a/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/HttpRequest.java b/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/HttpRequest.java
index ff80a8a845d..6c4759915b2 100644
--- a/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/HttpRequest.java
+++ b/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/HttpRequest.java
@@ -9,12 +9,14 @@ import com.yahoo.jdisc.handler.RequestHandler;
import com.yahoo.jdisc.handler.ResponseHandler;
import com.yahoo.jdisc.http.servlet.ServletOrJdiscHttpRequest;
import com.yahoo.jdisc.service.CurrentContainer;
-import org.jboss.netty.handler.codec.http.QueryStringDecoder;
+import org.eclipse.jetty.http.HttpURI;
+import org.eclipse.jetty.util.MultiMap;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.net.URI;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
@@ -84,7 +86,7 @@ public class HttpRequest extends Request implements ServletOrJdiscHttpRequest {
this.method = method;
this.version = version;
this.remoteAddress = remoteAddress;
- this.parameters.putAll(new QueryStringDecoder(uri.toString(), true).getParameters());
+ this.parameters.putAll(getUriQueryParameters(uri));
if (connectedAtMillis != null) {
this.connectedAt = connectedAtMillis;
} else {
@@ -102,7 +104,7 @@ public class HttpRequest extends Request implements ServletOrJdiscHttpRequest {
this.method = method;
this.version = version;
this.remoteAddress = null;
- this.parameters.putAll(new QueryStringDecoder(uri.toString(), true).getParameters());
+ this.parameters.putAll(getUriQueryParameters(uri));
this.connectedAt = creationTime(TimeUnit.MILLISECONDS);
} catch (RuntimeException e) {
release();
@@ -110,6 +112,18 @@ public class HttpRequest extends Request implements ServletOrJdiscHttpRequest {
}
}
+ private static Map<String, List<String>> getUriQueryParameters(URI uri) {
+ MultiMap<String> queryParameters = new MultiMap<>();
+ new HttpURI(uri).decodeQueryTo(queryParameters);
+
+ // Do a deep copy so we do not leak Jetty classes outside
+ Map<String, List<String>> deepCopiedQueryParameters = new HashMap<>();
+ for (Map.Entry<String, List<String>> entry : queryParameters.entrySet()) {
+ deepCopiedQueryParameters.put(entry.getKey(), new ArrayList<>(entry.getValue()));
+ }
+ return deepCopiedQueryParameters;
+ }
+
public Method getMethod() {
return method;
}
diff --git a/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/HttpRequestTestCase.java b/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/HttpRequestTestCase.java
index 8f26d9c38b0..53291c850c2 100644
--- a/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/HttpRequestTestCase.java
+++ b/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/HttpRequestTestCase.java
@@ -4,9 +4,6 @@ package com.yahoo.jdisc.http;
import com.yahoo.jdisc.Container;
import com.yahoo.jdisc.Request;
import com.yahoo.jdisc.service.CurrentContainer;
-import org.jboss.netty.handler.codec.http.HttpHeaders;
-import org.jboss.netty.handler.codec.http.HttpMethod;
-import org.jboss.netty.handler.codec.http.HttpVersion;
import org.testng.annotations.Test;
import java.net.InetSocketAddress;
@@ -30,27 +27,6 @@ import static org.testng.AssertJUnit.assertTrue;
public class HttpRequestTestCase {
@Test
- public void requireThatMethodIsCompatibleWithNetty() {
- assertMethod(HttpRequest.Method.OPTIONS, HttpMethod.OPTIONS);
- assertMethod(HttpRequest.Method.GET, HttpMethod.GET);
- assertMethod(HttpRequest.Method.HEAD, HttpMethod.HEAD);
- assertMethod(HttpRequest.Method.POST, HttpMethod.POST);
- assertMethod(HttpRequest.Method.PUT, HttpMethod.PUT);
- assertMethod(HttpRequest.Method.PATCH, HttpMethod.PATCH);
- assertMethod(HttpRequest.Method.DELETE, HttpMethod.DELETE);
- assertMethod(HttpRequest.Method.TRACE, HttpMethod.TRACE);
- assertMethod(HttpRequest.Method.CONNECT, HttpMethod.CONNECT);
- assertEquals(9, HttpRequest.Method.values().length);
- }
-
- @Test
- public void requireThatVersionIsCompatibleWithNetty() {
- assertVersion(HttpRequest.Version.HTTP_1_0, HttpVersion.HTTP_1_0);
- assertVersion(HttpRequest.Version.HTTP_1_1, HttpVersion.HTTP_1_1);
- assertEquals(2, HttpRequest.Version.values().length);
- }
-
- @Test
public void requireThatSimpleServerConstructorsUseReasonableDefaults() {
final URI uri = URI.create("http://localhost/");
HttpRequest request = HttpRequest.newServerRequest(mockContainer(), uri);
@@ -214,18 +190,6 @@ public class HttpRequestTestCase {
assertEquals(cookies, request.decodeCookieHeader());
}
- private static void assertMethod(final HttpRequest.Method discMethod, final HttpMethod nettyMethod) {
- assertEquals(discMethod, HttpRequest.Method.valueOf(nettyMethod.getName()));
- assertEquals(discMethod, HttpRequest.Method.valueOf(nettyMethod.toString()));
- assertEquals(nettyMethod, HttpMethod.valueOf(discMethod.toString()));
- }
-
- private static void assertVersion(final HttpRequest.Version discVersion, final HttpVersion nettyVersion) {
- assertEquals(discVersion, HttpRequest.Version.fromString(nettyVersion.getText()));
- assertEquals(discVersion, HttpRequest.Version.fromString(nettyVersion.toString()));
- assertEquals(nettyVersion, HttpVersion.valueOf(discVersion.toString()));
- }
-
private static HttpRequest newRequest(final HttpRequest.Version version) throws Exception {
return HttpRequest.newServerRequest(
mockContainer(),
diff --git a/pom.xml b/pom.xml
index df81809c60e..6956e7344e2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -882,6 +882,11 @@
<version>${jetty.version}</version>
</dependency>
<dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>