Am 2020-01-14 um 18:09 schrieb ma...@apache.org:
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
      new e6f26fa  Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=64074
e6f26fa is described below

commit e6f26fa9d5daf18e994787de65b150f0fc03f29d
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Jan 14 17:09:01 2020 +0000

     Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=64074
InputStreams for directories obtained from resource URLs now return a
     directory listing consistent with the behaviour of FileURLConnection.
     In addition to restoring the behaviour that was lost as a result of the
     introduction of CachedResourceURLConnection, it expands the feature to
     include packedWARs and to take account of resource JARs.
---
  .../catalina/webresources/CachedResource.java      | 34 ++++++++++++-
  .../catalina/webresources/TestCachedResource.java  | 57 +++++++++++++++++++++-
  2 files changed, 88 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/webresources/CachedResource.java 
b/java/org/apache/catalina/webresources/CachedResource.java
index 712a463..b77862a 100644
--- a/java/org/apache/catalina/webresources/CachedResource.java
+++ b/java/org/apache/catalina/webresources/CachedResource.java
@@ -24,8 +24,12 @@ import java.net.MalformedURLException;
  import java.net.URL;
  import java.net.URLConnection;
  import java.net.URLStreamHandler;
+import java.nio.charset.Charset;
  import java.security.Permission;
  import java.security.cert.Certificate;
+import java.text.Collator;
+import java.util.Arrays;
+import java.util.Locale;
  import java.util.jar.JarEntry;
  import java.util.jar.JarFile;
  import java.util.jar.Manifest;
@@ -412,6 +416,22 @@ public class CachedResource implements WebResource {
      }
+ /*
+     * Mimics the behaviour of FileURLConnection.getInputStream for a 
directory.
+     * Deliberately uses default locale.
+     */
+    private static InputStream buildInputStream(String[] files) {
+        Arrays.sort(files, Collator.getInstance(Locale.getDefault()));
+        StringBuilder result = new StringBuilder();
+        for (String file : files) {
+            result.append(file);
+            // Every entry is followed by \n including the last
+            result.append('\n');

Why didn't you choose System.lineSeparator()?

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

Reply via email to