hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r1356939 - /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
Date Tue, 03 Jul 2012 20:55:30 GMT
Author: todd
Date: Tue Jul  3 20:55:29 2012
New Revision: 1356939

URL: http://svn.apache.org/viewvc?rev=1356939&view=rev
Log:
HDFS-3574. Fix small race and do some cleanup in GetImageServlet. Contributed by Todd Lipcon.

Modified:
    hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java?rev=1356939&r1=1356938&r2=1356939&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
(original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ServletUtil.java
Tue Jul  3 20:55:29 2012
@@ -60,6 +60,20 @@ public class ServletUtil {
     s = s.trim();
     return s.length() == 0? null: s;
   }
+  
+  /**
+   * @return a long value as passed in the given parameter, throwing
+   * an exception if it is not present or if it is not a valid number.
+   */
+  public static long parseLongParam(ServletRequest request, String param)
+      throws IOException {
+    String paramStr = request.getParameter(param);
+    if (paramStr == null) {
+      throw new IOException("Invalid request has no " + param + " parameter");
+    }
+    
+    return Long.valueOf(paramStr);
+  }
 
   public static final String HTML_TAIL = "<hr />\n"
     + "<a href='http://hadoop.apache.org/core'>Hadoop</a>, " 



Mime
View raw message