[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



commit ff82fdaa8a58ace4719a694cbd2b3c2fb11d2ec4
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
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;
     }
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits