From: markt Date: Thu, 24 Jun 2010 13:10:41 +0000 (+0000) Subject: Fix the Eclipse warnings and as a result better handle directory creation failures X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=66c446c7b639ef73b28ee2da451aab7ac16ed63e;p=tomcat7.0 Fix the Eclipse warnings and as a result better handle directory creation failures git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@957539 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/manager/host/HostManagerServlet.java b/java/org/apache/catalina/manager/host/HostManagerServlet.java index 64c4576b5..e34dd5091 100644 --- a/java/org/apache/catalina/manager/host/HostManagerServlet.java +++ b/java/org/apache/catalina/manager/host/HostManagerServlet.java @@ -102,7 +102,7 @@ public class HostManagerServlet /** * The Context container associated with our web application. */ - protected Context context = null; + protected transient Context context = null; /** @@ -114,19 +114,19 @@ public class HostManagerServlet /** * The associated host. */ - protected Host installedHost = null; + protected transient Host installedHost = null; /** * The associated engine. */ - protected Engine engine = null; + protected transient Engine engine = null; /** * MBean server. */ - protected MBeanServer mBeanServer = null; + protected transient MBeanServer mBeanServer = null; /** @@ -139,7 +139,7 @@ public class HostManagerServlet /** * The Wrapper container associated with this servlet. */ - protected Wrapper wrapper = null; + protected transient Wrapper wrapper = null; // ----------------------------------------------- ContainerServlet Methods @@ -372,7 +372,12 @@ public class HostManagerServlet appBaseFile = file; } if (!appBaseFile.exists()) { - appBaseFile.mkdirs(); + if (!appBaseFile.mkdirs()) { + writer.println(sm.getString( + "hostManagerServlet.appBaseCreateFail", + appBaseFile.toString(), name)); + return; + } } // Create base for config files @@ -380,6 +385,11 @@ public class HostManagerServlet // Copy manager.xml if requested if (manager) { + if (configBaseFile == null) { + writer.println(sm.getString( + "hostManagerServlet.configBaseCreateFail", name)); + return; + } InputStream is = null; OutputStream os = null; try { @@ -657,7 +667,11 @@ public class HostManagerServlet if (installedHost != null) { configBase = new File(configBase, hostName); } - configBase.mkdirs(); + if (!configBase.exists()) { + if (!configBase.mkdirs()) { + return null; + } + } return configBase; } diff --git a/java/org/apache/catalina/manager/host/LocalStrings.properties b/java/org/apache/catalina/manager/host/LocalStrings.properties index bf0f55191..35e48cf56 100644 --- a/java/org/apache/catalina/manager/host/LocalStrings.properties +++ b/java/org/apache/catalina/manager/host/LocalStrings.properties @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +hostManagerServlet.appBaseCreateFail=FAIL - Failed to create appBase [{0}] for host [{1}] +hostManagerServlet.configBaseCreateFail=FAIL - Failed to identify configBase for host [{0}] hostManagerServlet.noCommand=FAIL - No command was specified hostManagerServlet.postCommand=FAIL - Tried to use command {0} via a GET request but POST is required hostManagerServlet.unknownCommand=FAIL - Unknown command {0} diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 44e6a1752..c447f52d3 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -107,6 +107,10 @@ expiration features. Also switch the manager application to the generic CSRF protection filter. (markt) + + Better handle failure to create directories required for new hosts in + the Host Manager application. (markt) +