struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject svn commit: r1328528 - /struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
Date Fri, 20 Apr 2012 22:23:26 GMT
Author: lukaszlenart
Date: Fri Apr 20 22:23:26 2012
New Revision: 1328528

URL: http://svn.apache.org/viewvc?rev=1328528&view=rev
Log:
WW-3801 adds logic to clean ups uploaded files

Modified:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/PrepareOperations.java

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/PrepareOperations.java?rev=1328528&r1=1328527&r2=1328528&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
Fri Apr 20 22:23:26 2012
@@ -20,23 +20,22 @@
  */
 package org.apache.struts2.dispatcher.ng;
 
-import org.apache.struts2.dispatcher.Dispatcher;
-import org.apache.struts2.dispatcher.mapper.ActionMapping;
-import org.apache.struts2.dispatcher.mapper.ActionMapper;
-import org.apache.struts2.StrutsException;
-import org.apache.struts2.RequestUtils;
-
-import javax.servlet.ServletException;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStackFactory;
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
+import org.apache.struts2.RequestUtils;
+import org.apache.struts2.StrutsConstants;
+import org.apache.struts2.StrutsException;
+import org.apache.struts2.dispatcher.Dispatcher;
+import org.apache.struts2.dispatcher.mapper.ActionMapper;
+import org.apache.struts2.dispatcher.mapper.ActionMapping;
 
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.List;
@@ -47,6 +46,8 @@ import java.util.regex.Pattern;
  */
 public class PrepareOperations {
 
+    private static final Logger LOG = LoggerFactory.getLogger(PrepareOperations.class);
+
     private ServletContext servletContext;
     private Dispatcher dispatcher;
     private static final String STRUTS_ACTION_MAPPING_KEY = "struts.actionMapping";
@@ -98,10 +99,18 @@ public class PrepareOperations {
                 return;
             }
         }
-
         // always clean up the thread request, even if an action hasn't been executed
-        ActionContext.setContext(null);
-        Dispatcher.setInstance(null);
+        try {
+            dispatcher.cleanUpRequest(request);
+        } catch (IOException e) {
+            if (LOG.isWarnEnabled()) {
+                LOG.warn("Cannot clean up the request, some files can still remain in #1
after upload!", e,
+                        StrutsConstants.STRUTS_MULTIPART_SAVEDIR);
+            }
+        } finally {
+            ActionContext.setContext(null);
+            Dispatcher.setInstance(null);
+        }
     }
 
     /**
@@ -173,7 +182,7 @@ public class PrepareOperations {
      */
     public void cleanupDispatcher() {
         if (dispatcher == null) {
-            throw new StrutsException("something is seriously wrong, Dispatcher is not initialized
(null) ");
+            throw new StrutsException("Something is seriously wrong, Dispatcher is not initialized
(null) ");
         } else {
             try {
                 dispatcher.cleanup();



Mime
View raw message