aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Becker2013-08-13 07:50:42 (EDT)
committerThomas Becker2013-08-13 07:50:42 (EDT)
commit9a7b0f5c1049100db34a4bb539f1aca146fa1050 (patch)
treeed8aede402fbd55c25919fbbc0657f6d0c1f8e72
parent75f87a289a87e0b8d8ae7acb199f80e881baff50 (diff)
downloadorg.eclipse.jetty.project-9a7b0f5c1049100db34a4bb539f1aca146fa1050.zip
org.eclipse.jetty.project-9a7b0f5c1049100db34a4bb539f1aca146fa1050.tar.gz
org.eclipse.jetty.project-9a7b0f5c1049100db34a4bb539f1aca146fa1050.tar.bz2
412938 Request.setCharacterEncoding now throws UnsupportedEncodingException instead of UnsupportedCharsetException
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/Request.java12
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java33
2 files changed, 26 insertions, 19 deletions
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java
index c3733f4..c6db08c 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java
@@ -28,6 +28,7 @@ import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.charset.Charset;
+import java.nio.charset.UnsupportedCharsetException;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Collection;
@@ -1701,7 +1702,16 @@ public class Request implements HttpServletRequest
// check encoding is supported
if (!StringUtil.isUTF8(encoding))
- Charset.forName(encoding);
+ {
+ try
+ {
+ Charset.forName(encoding);
+ }
+ catch (UnsupportedCharsetException e)
+ {
+ throw new UnsupportedEncodingException(e.getMessage());
+ }
+ }
}
/* ------------------------------------------------------------ */
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java
index 370c8e2..e2d94bf 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java
@@ -18,26 +18,17 @@
package org.eclipse.jetty.server;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
+import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Enumeration;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-
import javax.servlet.MultipartConfigElement;
import javax.servlet.ServletException;
import javax.servlet.ServletRequestEvent;
@@ -58,10 +49,17 @@ import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.log.StdErrLog;
import org.hamcrest.Matchers;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
public class RequestTest
{
private static final Logger LOG = Log.getLogger(RequestTest.class);
@@ -466,13 +464,6 @@ public class RequestTest
assertEquals("remote",results.get(i++));
assertEquals("::1",results.get(i++));
assertEquals("8888",results.get(i++));
-
-
-
-
-
-
-
}
@Test
@@ -1042,6 +1033,12 @@ public class RequestTest
}
}
+ @Test(expected = UnsupportedEncodingException.class)
+ public void testNotSupportedCharacterEncoding() throws UnsupportedEncodingException
+ {
+ Request request = new Request(null, null);
+ request.setCharacterEncoding("doesNotExist");
+ }
interface RequestTester
{