[tor-commits] [onionoo/release] Use parameterized map for parameters.

karsten at torproject.org karsten at torproject.org
Mon Sep 10 15:29:14 UTC 2018


commit ff82fdaa8a58ace4719a694cbd2b3c2fb11d2ec4
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Mon Aug 20 16:13:05 2018 +0200

    Use parameterized map for parameters.
---
 .../org/torproject/onionoo/server/HttpServletRequestWrapper.java    | 3 +--
 src/main/java/org/torproject/onionoo/server/ResourceServlet.java    | 6 +++---
 .../java/org/torproject/onionoo/server/ResourceServletTest.java     | 3 +--
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/torproject/onionoo/server/HttpServletRequestWrapper.java b/src/main/java/org/torproject/onionoo/server/HttpServletRequestWrapper.java
index 904e55c..c8771c8 100644
--- a/src/main/java/org/torproject/onionoo/server/HttpServletRequestWrapper.java
+++ b/src/main/java/org/torproject/onionoo/server/HttpServletRequestWrapper.java
@@ -20,8 +20,7 @@ public class HttpServletRequestWrapper {
     return this.request.getRequestURI();
   }
 
-  @SuppressWarnings("rawtypes")
-  protected Map getParameterMap() {
+  protected Map<String, String[]> getParameterMap() {
     return this.request.getParameterMap();
   }
 
diff --git a/src/main/java/org/torproject/onionoo/server/ResourceServlet.java b/src/main/java/org/torproject/onionoo/server/ResourceServlet.java
index 1c72b9e..dce5601 100644
--- a/src/main/java/org/torproject/onionoo/server/ResourceServlet.java
+++ b/src/main/java/org/torproject/onionoo/server/ResourceServlet.java
@@ -133,10 +133,10 @@ public class ResourceServlet extends HttpServlet {
     /* Extract parameters either from the old-style URI or from request
      * parameters. */
     Map<String, String> parameterMap = new HashMap<>();
-    for (Object parameterKey : request.getParameterMap().keySet()) {
+    for (String parameterKey : request.getParameterMap().keySet()) {
       String[] parameterValues =
-          request.getParameterValues((String) parameterKey);
-      parameterMap.put((String) parameterKey, parameterValues[0]);
+          request.getParameterValues(parameterKey);
+      parameterMap.put(parameterKey, parameterValues[0]);
     }
 
     /* Make sure that the request doesn't contain any unknown
diff --git a/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java b/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java
index 58bab5d..74fec21 100644
--- a/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java
+++ b/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java
@@ -64,8 +64,7 @@ public class ResourceServletTest {
       return this.requestUri;
     }
 
-    @SuppressWarnings("rawtypes")
-    protected Map getParameterMap() {
+    protected Map<String, String[]> getParameterMap() {
       return this.parameterMap;
     }
 





More information about the tor-commits mailing list