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

remm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new ea0cdb0449 Improve error reporting of file copy errors
ea0cdb0449 is described below

commit ea0cdb044941f1ced5baf236aba395c170030768
Author: remm <r...@apache.org>
AuthorDate: Mon May 19 14:21:36 2025 +0200

    Improve error reporting of file copy errors
    
    BZ69694.
---
 .../catalina/manager/LocalStrings.properties       |  2 +-
 .../apache/catalina/manager/ManagerServlet.java    | 23 +++++++++++++++++-----
 webapps/docs/changelog.xml                         |  4 ++++
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/catalina/manager/LocalStrings.properties 
b/java/org/apache/catalina/manager/LocalStrings.properties
index 148833de19..9521873a49 100644
--- a/java/org/apache/catalina/manager/LocalStrings.properties
+++ b/java/org/apache/catalina/manager/LocalStrings.properties
@@ -122,7 +122,7 @@ jmxProxyServlet.noOperationOnBean=Cannot find operation 
[{0}] with [{1}] argumen
 
 managerServlet.alreadyContext=FAIL - Application already exists at path [{0}]
 managerServlet.certsNotAvailable=Certificate information cannot be obtained 
from this connector at runtime
-managerServlet.copyError=Could not copy configuration file from path [{0}]
+managerServlet.copyFail=FAIL - Unable to copy [{0}] to [{1}], details of the 
error may be in the server logs
 managerServlet.deleteFail=FAIL - Unable to delete [{0}]. The continued 
presence of this file may cause problems.
 managerServlet.deployFailed=FAIL - Failed to deploy application at context 
path [{0}]
 managerServlet.deployed=OK - Deployed application at context path [{0}]
diff --git a/java/org/apache/catalina/manager/ManagerServlet.java 
b/java/org/apache/catalina/manager/ManagerServlet.java
index 40aca5e1cf..2c0f6f07cd 100644
--- a/java/org/apache/catalina/manager/ManagerServlet.java
+++ b/java/org/apache/catalina/manager/ManagerServlet.java
@@ -736,7 +736,8 @@ public class ManagerServlet extends HttpServlet implements 
ContainerServlet {
                             return;
                         }
                         if (!ExpandWar.copy(new File(config), new 
File(configBase, baseName + ".xml"))) {
-                            throw new 
Exception(sm.getString("managerServlet.copyError", config));
+                            
writer.println(smClient.getString("managerServlet.copyFail", new File(config), 
new File(configBase, baseName + ".xml")));
+                            return;
                         }
                     }
                     // Upload WAR
@@ -754,7 +755,10 @@ public class ManagerServlet extends HttpServlet implements 
ContainerServlet {
                     }
                     if (tag != null) {
                         // Copy WAR to the host's appBase
-                        ExpandWar.copy(uploadedWar, deployedWar);
+                        if (!ExpandWar.copy(uploadedWar, deployedWar)) {
+                            
writer.println(smClient.getString("managerServlet.copyFail", uploadedWar, 
deployedWar));
+                            return;
+                        }
                     }
                 } finally {
                     removeServiced(name);
@@ -808,7 +812,10 @@ public class ManagerServlet extends HttpServlet implements 
ContainerServlet {
                         
writer.println(smClient.getString("managerServlet.deleteFail", deployedWar));
                         return;
                     }
-                    ExpandWar.copy(localWar, deployedWar);
+                    if (!ExpandWar.copy(localWar, deployedWar)) {
+                        
writer.println(smClient.getString("managerServlet.copyFail", localWar, 
deployedWar));
+                        return;
+                    }
                 } finally {
                     removeServiced(name);
                 }
@@ -902,7 +909,10 @@ public class ManagerServlet extends HttpServlet implements 
ContainerServlet {
                                 
writer.println(smClient.getString("managerServlet.deleteFail", 
localConfigFile));
                                 return;
                             }
-                            ExpandWar.copy(configFile, localConfigFile);
+                            if (!ExpandWar.copy(configFile, localConfigFile)) {
+                                
writer.println(smClient.getString("managerServlet.copyFail", configFile, 
localConfigFile));
+                                return;
+                            }
                         }
                     }
                     if (war != null) {
@@ -922,7 +932,10 @@ public class ManagerServlet extends HttpServlet implements 
ContainerServlet {
                                 
writer.println(smClient.getString("managerServlet.deleteFail", localWarFile));
                                 return;
                             }
-                            ExpandWar.copy(warFile, localWarFile);
+                            if (!ExpandWar.copy(warFile, localWarFile)) {
+                                
writer.println(smClient.getString("managerServlet.copyFail", warFile, 
localWarFile));
+                                return;
+                            }
                         }
                     }
                 } finally {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 74a4b6c710..36fe25e532 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -228,6 +228,10 @@
   <subsection name="Web applications">
     <changelog>
       <!-- Entries for backport and removal before 12.0.0-M1 below this line 
-->
+      <fix>
+        <bug>69694</bug>: Improve error reporting of deployment tasks done
+        using the manager webapp when a copy operation fails. (remm)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Other">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to