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

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 59a5e45d320b2a49b7f1aaa4f0738aa5d7d8e854
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Sun Feb 4 18:40:53 2024 +0000

    Align with 9.0.x
---
 .../catalina/startup/ClassLoaderFactory.java       |  2 +-
 .../org/apache/catalina/startup/ContextConfig.java |  1 -
 java/org/apache/catalina/startup/ExpandWar.java    |  2 +-
 .../apache/catalina/startup/HomesUserDatabase.java |  8 ----
 java/org/apache/catalina/startup/HostConfig.java   | 44 +++++++++++++---------
 .../catalina/startup/LocalStrings.properties       |  3 ++
 .../catalina/startup/LocalStrings_fr.properties    |  3 ++
 .../catalina/startup/LocalStrings_ja.properties    |  3 ++
 .../catalina/startup/LocalStrings_ko.properties    |  3 ++
 .../catalina/startup/LocalStrings_zh_CN.properties |  3 ++
 java/org/apache/catalina/startup/Tool.java         |  5 ++-
 11 files changed, 47 insertions(+), 30 deletions(-)

diff --git a/java/org/apache/catalina/startup/ClassLoaderFactory.java 
b/java/org/apache/catalina/startup/ClassLoaderFactory.java
index 76689fd37b..3dc4469a34 100644
--- a/java/org/apache/catalina/startup/ClassLoaderFactory.java
+++ b/java/org/apache/catalina/startup/ClassLoaderFactory.java
@@ -85,7 +85,7 @@ public final class ClassLoaderFactory {
                 if (!file.canRead()) {
                     continue;
                 }
-                file = new File(file.getCanonicalPath() + File.separator);
+                file = new File(file.getCanonicalPath());
                 URL url = file.toURI().toURL();
                 if (log.isDebugEnabled()) {
                     log.debug("  Including directory " + url);
diff --git a/java/org/apache/catalina/startup/ContextConfig.java 
b/java/org/apache/catalina/startup/ContextConfig.java
index fe0a1bc15c..7638576136 100644
--- a/java/org/apache/catalina/startup/ContextConfig.java
+++ b/java/org/apache/catalina/startup/ContextConfig.java
@@ -612,7 +612,6 @@ public class ContextConfig implements LifecycleListener {
                         docBaseAbsolute = ExpandWar.expand(host, war, 
pathName);
                         docBaseAbsoluteFile = new File(docBaseAbsolute);
                     } else {
-                        docBaseAbsolute = 
docBaseAbsoluteFileWar.getAbsolutePath();
                         docBaseAbsoluteFile = docBaseAbsoluteFileWar;
                         ExpandWar.validate(host, war, pathName);
                     }
diff --git a/java/org/apache/catalina/startup/ExpandWar.java 
b/java/org/apache/catalina/startup/ExpandWar.java
index fe2a46037b..a100dfd2db 100644
--- a/java/org/apache/catalina/startup/ExpandWar.java
+++ b/java/org/apache/catalina/startup/ExpandWar.java
@@ -65,7 +65,7 @@ public class ExpandWar {
      * @exception IllegalArgumentException if this is not a "jar:" URL or if 
the WAR file is invalid
      * @exception IOException              if an input/output error was 
encountered during expansion
      *
-     * @return The absolute path to the expanded directory foe the given WAR
+     * @return The absolute path to the expanded directory for the given WAR
      */
     public static String expand(Host host, URL war, String pathname) throws 
IOException {
 
diff --git a/java/org/apache/catalina/startup/HomesUserDatabase.java 
b/java/org/apache/catalina/startup/HomesUserDatabase.java
index a2e49d78f9..fd8caf78d7 100644
--- a/java/org/apache/catalina/startup/HomesUserDatabase.java
+++ b/java/org/apache/catalina/startup/HomesUserDatabase.java
@@ -30,14 +30,6 @@ import java.util.Map;
  */
 public final class HomesUserDatabase implements UserDatabase {
 
-    /**
-     * Initialize a new instance of this user database component.
-     */
-    public HomesUserDatabase() {
-        super();
-    }
-
-
     /**
      * The set of home directories for all defined users, keyed by username.
      */
diff --git a/java/org/apache/catalina/startup/HostConfig.java 
b/java/org/apache/catalina/startup/HostConfig.java
index ea844c2541..8f0436d2dc 100644
--- a/java/org/apache/catalina/startup/HostConfig.java
+++ b/java/org/apache/catalina/startup/HostConfig.java
@@ -16,12 +16,12 @@
  */
 package org.apache.catalina.startup;
 
-import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.nio.file.Files;
@@ -65,6 +65,7 @@ import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.core.StandardHost;
 import org.apache.catalina.security.DeployXmlPermission;
 import org.apache.catalina.util.ContextName;
+import org.apache.catalina.util.IOTools;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.ExceptionUtils;
@@ -231,7 +232,7 @@ public class HostConfig implements LifecycleListener {
                     }
                 } catch (MalformedURLException e) {
                     // Should never happen
-                    log.warn("hostConfig.docBaseUrlInvalid", e);
+                    log.warn(sm.getString("hostConfig.docBaseUrlInvalid"), e);
                 }
             }
         }
@@ -631,6 +632,11 @@ public class HostConfig implements LifecycleListener {
                 }
             }
 
+            if (context.getPath() != null) {
+                log.warn(sm.getString("hostConfig.deployDescriptor.path", 
context.getPath(),
+                        contextXml.getAbsolutePath()));
+            }
+
             Class<?> clazz = Class.forName(host.getConfigClass());
             LifecycleListener listener = (LifecycleListener) 
clazz.getConstructor().newInstance();
             context.addLifecycleListener(listener);
@@ -654,6 +660,17 @@ public class HostConfig implements LifecycleListener {
                     if 
(docBase.getAbsolutePath().toLowerCase(Locale.ENGLISH).endsWith(".war")) {
                         isExternalWar = true;
                     }
+                    // Check that a WAR or DIR in the appBase is not 'hidden'
+                    File war = new File(host.getAppBaseFile(), 
cn.getBaseName() + ".war");
+                    if (war.exists()) {
+                        
log.warn(sm.getString("hostConfig.deployDescriptor.hiddenWar", 
contextXml.getAbsolutePath(),
+                                war.getAbsolutePath()));
+                    }
+                    File dir = new File(host.getAppBaseFile(), 
cn.getBaseName());
+                    if (dir.exists()) {
+                        
log.warn(sm.getString("hostConfig.deployDescriptor.hiddenDir", 
contextXml.getAbsolutePath(),
+                                dir.getAbsolutePath()));
+                    }
                 } else {
                     
log.warn(sm.getString("hostConfig.deployDescriptor.localDocBaseSpecified", 
docBase));
                     // Ignore specified docBase
@@ -955,17 +972,8 @@ public class HostConfig implements LifecycleListener {
                 try (JarFile jar = new JarFile(war)) {
                     JarEntry entry = 
jar.getJarEntry(Constants.ApplicationContextXml);
                     try (InputStream istream = jar.getInputStream(entry);
-                            FileOutputStream fos = new FileOutputStream(xml);
-                            BufferedOutputStream ostream = new 
BufferedOutputStream(fos, 1024)) {
-                        byte buffer[] = new byte[1024];
-                        while (true) {
-                            int n = istream.read(buffer);
-                            if (n < 0) {
-                                break;
-                            }
-                            ostream.write(buffer, 0, n);
-                        }
-                        ostream.flush();
+                            OutputStream ostream = new FileOutputStream(xml)) {
+                        IOTools.flow(istream, ostream);
                     }
                 } catch (IOException e) {
                     /* Ignore */
@@ -1345,10 +1353,12 @@ public class HostConfig implements LifecycleListener {
             } else {
                 // There is a chance the the resource was only missing
                 // temporarily eg renamed during a text editor save
-                try {
-                    Thread.sleep(500);
-                } catch (InterruptedException e1) {
-                    // Ignore
+                if (resource.exists() || 
!resource.getName().toLowerCase(Locale.ENGLISH).endsWith(".war")) {
+                    try {
+                        Thread.sleep(500);
+                    } catch (InterruptedException e1) {
+                        // Ignore
+                    }
                 }
                 // Recheck the resource to see if it was really deleted
                 if (resource.exists()) {
diff --git a/java/org/apache/catalina/startup/LocalStrings.properties 
b/java/org/apache/catalina/startup/LocalStrings.properties
index 1db37ba354..fdf5246f4e 100644
--- a/java/org/apache/catalina/startup/LocalStrings.properties
+++ b/java/org/apache/catalina/startup/LocalStrings.properties
@@ -103,7 +103,10 @@ hostConfig.deployDescriptor=Deploying deployment 
descriptor [{0}]
 hostConfig.deployDescriptor.blocked=The web application with context path 
[{0}] was not deployed because it contained a deployment descriptor [{1}] which 
may include configuration necessary for the secure deployment of the 
application but processing of deployment descriptors is prevented by the 
deployXML setting of this host. An appropriate descriptor should be created at 
[{2}] to deploy this application.
 hostConfig.deployDescriptor.error=Error deploying deployment descriptor [{0}]
 hostConfig.deployDescriptor.finished=Deployment of deployment descriptor [{0}] 
has finished in [{1}] ms
+hostConfig.deployDescriptor.hiddenDir=Deployment of deployment descriptor 
[{0}] with an external docBase means the directory [{1}] in the appBase will be 
ignored
+hostConfig.deployDescriptor.hiddenWar=Deployment of deployment descriptor 
[{0}] with an external docBase means the WAR [{1}] in the appBase will be 
ignored
 hostConfig.deployDescriptor.localDocBaseSpecified=A docBase [{0}] inside the 
host appBase has been specified, and will be ignored
+hostConfig.deployDescriptor.path=The path attribute with value [{0}] in 
deployment descriptor [{1}] has been ignored
 hostConfig.deployDescriptor.threaded.error=Error waiting for multi-thread 
deployment of deployment descriptors to complete
 hostConfig.deployDir=Deploying web application directory [{0}]
 hostConfig.deployDir.error=Error deploying web application directory [{0}]
diff --git a/java/org/apache/catalina/startup/LocalStrings_fr.properties 
b/java/org/apache/catalina/startup/LocalStrings_fr.properties
index e729111546..ba1736c272 100644
--- a/java/org/apache/catalina/startup/LocalStrings_fr.properties
+++ b/java/org/apache/catalina/startup/LocalStrings_fr.properties
@@ -100,7 +100,10 @@ hostConfig.deployDescriptor=Déploiement du descripteur de 
configuration [{0}]
 hostConfig.deployDescriptor.blocked=L''application web dont le chemin est 
[{0}] n''a pas été déployée car elle contenait un descripteur de déploiement 
[{1}] qui pourrait inclure de la configuration nécessaire pour le déploiement 
sécurisé de l''application mais ce traitement est empêché par le paramètre 
deployXML pour cet hôte, un descripteur approprié devrait être crée à [{2}] 
pour déployer cette application
 hostConfig.deployDescriptor.error=Erreur lors du déploiement du descripteur de 
configuration [{0}]
 hostConfig.deployDescriptor.finished=Le traitement du descripteur de 
déploiement [{0}] a pris [{1}] ms
+hostConfig.deployDescriptor.hiddenDir=Le déploiement du descripteur [{0}] avec 
une docBase externe signifie que le répertoire [{1}] qui est dans appBase sera 
ignoré
+hostConfig.deployDescriptor.hiddenWar=Le déploiement du descripteur [{0}] avec 
une docBase externe signifie que le WAR [{1}] qui est dans appBase sera ignoré
 hostConfig.deployDescriptor.localDocBaseSpecified=Un docBase [{0}] dans 
l''appBase de l''hôte a été spécifié et sera ignoré
+hostConfig.deployDescriptor.path=L''attribut path avec la valeur [{0}] dans le 
descripteur de déploiement [{1}] a été ignoré
 hostConfig.deployDescriptor.threaded.error=Erreur en attendant la fin du 
déploiement de descripteurs en parallèle
 hostConfig.deployDir=Déploiement du répertoire d''application web [{0}]
 hostConfig.deployDir.error=Erreur lors du déploiement du répertoire [{0}] de 
l''application web
diff --git a/java/org/apache/catalina/startup/LocalStrings_ja.properties 
b/java/org/apache/catalina/startup/LocalStrings_ja.properties
index 2d19ca6290..70801a55e8 100644
--- a/java/org/apache/catalina/startup/LocalStrings_ja.properties
+++ b/java/org/apache/catalina/startup/LocalStrings_ja.properties
@@ -100,7 +100,10 @@ hostConfig.deployDescriptor=配備記述子 [{0}] を配備します
 hostConfig.deployDescriptor.blocked=コンテキストパス [{0}] 
を持つWebアプリケーションは、アプリケーションのセキュアな配備に必要な設定が含まれている可能性がありますが、このホストのdeployXML設定によって処理が妨げられる配備記述子
 [{1}] が含まれていたため配備されていません。このアプリケーションを配備するには、[{2}] に適切な記述子を作成する必要があります。
 hostConfig.deployDescriptor.error=配備記述子 [{0}] を配備中のエラーです
 hostConfig.deployDescriptor.finished=配備記述子 [{0}] の展開が [{1}] ミリ秒で完了しました
+hostConfig.deployDescriptor.hiddenDir=外部のdocBaseを使用した配備記述子 [{0}] の配備は、appBaseの 
[{1}] ディレクトリが無視されることを意味します
+hostConfig.deployDescriptor.hiddenWar=配備記述子 [{0}] 
を外部のdocBaseとともに配備するとappBaseのWAR [{1}] が無視されます
 hostConfig.deployDescriptor.localDocBaseSpecified=docBase [{0}] はホストの appBase 
に含まれるため無視します。
+hostConfig.deployDescriptor.path=配備記述子 [{1}] の path 属性に指定された [{0}] は無視されました
 hostConfig.deployDescriptor.threaded.error=配備記述子のマルチスレッド配備の完了待機中のエラー
 hostConfig.deployDir=Web アプリケーションディレクトリ [{0}] を配備します
 hostConfig.deployDir.error=Webアプリケーションディレクトリ [{0}] を配備中のエラー
diff --git a/java/org/apache/catalina/startup/LocalStrings_ko.properties 
b/java/org/apache/catalina/startup/LocalStrings_ko.properties
index cb1531924c..ffcb3a92f0 100644
--- a/java/org/apache/catalina/startup/LocalStrings_ko.properties
+++ b/java/org/apache/catalina/startup/LocalStrings_ko.properties
@@ -100,7 +100,10 @@ hostConfig.deployDescriptor=배치 descriptor [{0}]을(를) 배치합니다.
 hostConfig.deployDescriptor.blocked=컨텍스트 경로 [{0}]의 웹 애플리케이션이 배치되지 않았습니다. 왜냐하면 
해당 애플리케이션의 안전한 배치에 필요한 설정들이 배치 descriptor [{1}]에 포함되어 있으나, 이 호스트의 deployXML 설정에 
의해 배치 descriptor들이 처리 되지 않았기 때문입니다. 이 애플리케이션을 배치하기 위해서는 적절한 descriptor가 [{2}]에 
생성되어야 합니다.
 hostConfig.deployDescriptor.error=배치 descriptor [{0}]을(를) 배치하는 중 오류 발생
 hostConfig.deployDescriptor.finished=배치 descriptor [{0}]의 배치가 [{1}] 밀리초 내에 
완료되었습니다.
+hostConfig.deployDescriptor.hiddenDir=외부 docBase를 사용하여 배치 descriptor [{0}]을(를) 
배치하는 것은, appBase 내의 디렉토리 [{1}]이(가) 무시될 것을 의미합니다.
+hostConfig.deployDescriptor.hiddenWar=외부 docBase를 포함한 배치 descriptor [{0}]의 
배치는, appBase 내의 WAR [{1}]이(가) 무시될 것을 의미합니다.
 hostConfig.deployDescriptor.localDocBaseSpecified=호스트 appBase 내의 docBase 
[{0}]이(가) 지정되었으나, 이는 무시될 것입니다.
+hostConfig.deployDescriptor.path=배치 descriptor [{1}] 내에서, [{0}] 값을 가진 path 속성은 
무시됩니다.
 hostConfig.deployDescriptor.threaded.error=배치 descriptor들을 배치하려는 멀티 쓰레드 작업이 
완료되기를 기다리는 중 오류 발생
 hostConfig.deployDir=웹 애플리케이션 디렉토리 [{0}]을(를) 배치합니다.
 hostConfig.deployDir.error=웹 애플리케이션 디렉토리 [{0}]을(를) 배치하는 중 오류 발생
diff --git a/java/org/apache/catalina/startup/LocalStrings_zh_CN.properties 
b/java/org/apache/catalina/startup/LocalStrings_zh_CN.properties
index ed0a953aac..8c85c77c5c 100644
--- a/java/org/apache/catalina/startup/LocalStrings_zh_CN.properties
+++ b/java/org/apache/catalina/startup/LocalStrings_zh_CN.properties
@@ -100,7 +100,10 @@ hostConfig.deployDescriptor=正在部署部署描述符[{0}]。
 
hostConfig.deployDescriptor.blocked=未部署上下文路径为[{0}]的Web应用程序,因为它包含一个部署描述符[{1}],该描述符可能包含安全部署应用程序所需的配置,但此主机的DeployXML设置阻止了部署描述符的处理。应该在[{2}]创建适当的描述符来部署此应用程序。
 hostConfig.deployDescriptor.error=部署描述符[{0}]时出错
 hostConfig.deployDescriptor.finished=部署描述符[{0}]的部署已在[{1}]ms内完成
+hostConfig.deployDescriptor.hiddenDir=使用外部docBase部署部署描述符[{0}]意味着appBase中的目录[{1}]将被忽略
+hostConfig.deployDescriptor.hiddenWar=使用外部docBase部署部署描述符[{0}]意味着appBase中的WAR[{1}]将被忽略
 hostConfig.deployDescriptor.localDocBaseSpecified=在主机appBase 中指定了docBase 
[{0}],将被忽略
+hostConfig.deployDescriptor.path=部署描述符[{1}]中值为[{0}]的路径属性已被忽略
 hostConfig.deployDescriptor.threaded.error=等待部署描述符的多线程部署完成时出错
 hostConfig.deployDir=把web 应用程序部署到目录 [{0}]
 hostConfig.deployDir.error=无法部署应用目录 [{0}]
diff --git a/java/org/apache/catalina/startup/Tool.java 
b/java/org/apache/catalina/startup/Tool.java
index c8e1c34f60..68499c33c8 100644
--- a/java/org/apache/catalina/startup/Tool.java
+++ b/java/org/apache/catalina/startup/Tool.java
@@ -20,6 +20,7 @@ package org.apache.catalina.startup;
 import java.io.File;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -150,8 +151,8 @@ public final class Tool {
         // Construct the class loader we will be using
         ClassLoader classLoader = null;
         try {
-            ArrayList<File> packed = new ArrayList<>();
-            ArrayList<File> unpacked = new ArrayList<>();
+            List<File> packed = new ArrayList<>();
+            List<File> unpacked = new ArrayList<>();
             unpacked.add(new File(catalinaHome, "classes"));
             packed.add(new File(catalinaHome, "lib"));
             if (common) {


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

Reply via email to