This is an automated email from the ASF dual-hosted git repository.

aengineer pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 0a716bd  HDDS-2159. Fix Race condition in ProfileServlet#pid.
0a716bd is described below

commit 0a716bd3a5b38779bb07450acb3279e859bb7471
Author: Hanisha Koneru <hanishakon...@apache.org>
AuthorDate: Fri Sep 20 13:06:29 2019 -0700

    HDDS-2159. Fix Race condition in ProfileServlet#pid.
    
    Signed-off-by: Anu Engineer <aengin...@apache.org>
---
 .../java/org/apache/hadoop/hdds/server/ProfileServlet.java     | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git 
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ProfileServlet.java
 
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ProfileServlet.java
index 016445c..7cea582 100644
--- 
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ProfileServlet.java
+++ 
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ProfileServlet.java
@@ -119,7 +119,7 @@ public class ProfileServlet extends HttpServlet {
       Pattern.compile(FILE_PREFIX + "[0-9]+-[0-9A-Za-z\\-_]+-[0-9]+\\.[a-z]+");
 
   private Lock profilerLock = new ReentrantLock();
-  private Integer pid;
+  private final Integer pid;
   private String asyncProfilerHome;
   private transient Process process;
 
@@ -208,11 +208,11 @@ public class ProfileServlet extends HttpServlet {
       return;
     }
     // if pid is explicitly specified, use it else default to current process
-    pid = getInteger(req, "pid", pid);
+    Integer processId = getInteger(req, "pid", pid);
 
     // if pid is not specified in query param and if current process pid
     // cannot be determined
-    if (pid == null) {
+    if (processId == null) {
       resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
       setResponseHeader(resp);
       resp.getWriter().write(
@@ -243,7 +243,7 @@ public class ProfileServlet extends HttpServlet {
             //Should be in sync with FILE_NAME_PATTERN
             File outputFile =
                 OUTPUT_DIR.resolve(
-                    ProfileServlet.generateFileName(pid, output, event))
+                    ProfileServlet.generateFileName(processId, output, event))
                     .toFile();
             List<String> cmd = new ArrayList<>();
             cmd.add(asyncProfilerHome + PROFILER_SCRIPT);
@@ -288,7 +288,7 @@ public class ProfileServlet extends HttpServlet {
             if (reverse) {
               cmd.add("--reverse");
             }
-            cmd.add(pid.toString());
+            cmd.add(processId.toString());
             process = runCmdAsync(cmd);
 
             // set response and set refresh header to output location


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to