You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2019/07/29 10:07:32 UTC

[tomcat] branch 8.5.x updated (eb3c52f -> 4fa6a00)

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

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


    from eb3c52f  Fix typo in error message
     new 51f00c2  Align with master. Back-port simple clean-up.
     new b5c04d5  Align with master. Back-port i18n support.
     new 703f85a  SpotBugs Refactor to remove some duplicated (and unused) code.
     new 4fa6a00  Address a few more SpotBugs warnings

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/org/apache/catalina/startup/ExpandWar.java    | 13 +++-
 .../catalina/startup/LocalStrings.properties       |  3 +
 java/org/apache/catalina/startup/Tomcat.java       |  5 +-
 java/org/apache/catalina/util/URLEncoder.java      |  2 +-
 .../rewrite}/LocalStrings.properties               |  7 +-
 .../rewrite}/LocalStrings_fr.properties            |  6 +-
 .../valves/rewrite}/LocalStrings_ja.properties     |  9 +--
 .../catalina/valves/rewrite/RewriteCond.java       | 82 +++++++---------------
 .../catalina/valves/rewrite/RewriteRule.java       |  6 +-
 .../catalina/valves/rewrite/RewriteValve.java      | 39 +++++-----
 .../catalina/valves/rewrite/Substitution.java      |  3 +-
 .../org/apache/el/stream/StreamELResolverImpl.java |  7 +-
 res/findbugs/filter-false-positives.xml            | 12 ++++
 13 files changed, 101 insertions(+), 93 deletions(-)
 copy java/org/apache/catalina/{ha/authenticator => valves/rewrite}/LocalStrings.properties (74%)
 copy java/org/apache/catalina/{filters => valves/rewrite}/LocalStrings_fr.properties (69%)
 copy java/{javax/servlet => org/apache/catalina/valves/rewrite}/LocalStrings_ja.properties (72%)


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


[tomcat] 03/04: SpotBugs Refactor to remove some duplicated (and unused) code.

Posted by ma...@apache.org.
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 703f85abb7fbdb67ed9c2eea09832263a9b1bf09
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Apr 5 18:10:22 2018 +0000

    SpotBugs
    Refactor to remove some duplicated (and unused) code.
    
    git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1828459 13f79535-47bb-0310-9956-ffa450edef68
---
 .../catalina/valves/rewrite/RewriteCond.java       | 82 +++++++---------------
 1 file changed, 26 insertions(+), 56 deletions(-)

diff --git a/java/org/apache/catalina/valves/rewrite/RewriteCond.java b/java/org/apache/catalina/valves/rewrite/RewriteCond.java
index 973ba8f..47a904c 100644
--- a/java/org/apache/catalina/valves/rewrite/RewriteCond.java
+++ b/java/org/apache/catalina/valves/rewrite/RewriteCond.java
@@ -28,18 +28,22 @@ public class RewriteCond {
 
     public static class PatternCondition extends Condition {
         public Pattern pattern;
-        public Matcher matcher = null;
+        private ThreadLocal<Matcher> matcher = new ThreadLocal<>();
 
         @Override
         public boolean evaluate(String value, Resolver resolver) {
             Matcher m = pattern.matcher(value);
             if (m.matches()) {
-                matcher = m;
+                matcher.set(m);
                 return true;
             } else {
                 return false;
             }
         }
+
+        public Matcher getMatcher() {
+            return matcher.get();
+        }
     }
 
     public static class LexicalCondition extends Condition {
@@ -119,40 +123,46 @@ public class RewriteCond {
             condPattern = condPattern.substring(1);
         }
         if (condPattern.startsWith("<")) {
-            LexicalCondition condition = new LexicalCondition();
-            condition.type = -1;
-            condition.condition = condPattern.substring(1);
+            LexicalCondition ncondition = new LexicalCondition();
+            ncondition.type = -1;
+            ncondition.condition = condPattern.substring(1);
+            this.condition = ncondition;
         } else if (condPattern.startsWith(">")) {
-            LexicalCondition condition = new LexicalCondition();
-            condition.type = 1;
-            condition.condition = condPattern.substring(1);
+            LexicalCondition ncondition = new LexicalCondition();
+            ncondition.type = 1;
+            ncondition.condition = condPattern.substring(1);
+            this.condition = ncondition;
         } else if (condPattern.startsWith("=")) {
-            LexicalCondition condition = new LexicalCondition();
-            condition.type = 0;
-            condition.condition = condPattern.substring(1);
+            LexicalCondition ncondition = new LexicalCondition();
+            ncondition.type = 0;
+            ncondition.condition = condPattern.substring(1);
+            this.condition = ncondition;
         } else if (condPattern.equals("-d")) {
             ResourceCondition ncondition = new ResourceCondition();
             ncondition.type = 0;
+            this.condition = ncondition;
         } else if (condPattern.equals("-f")) {
             ResourceCondition ncondition = new ResourceCondition();
             ncondition.type = 1;
+            this.condition = ncondition;
         } else if (condPattern.equals("-s")) {
             ResourceCondition ncondition = new ResourceCondition();
             ncondition.type = 2;
+            this.condition = ncondition;
         } else {
-            PatternCondition condition = new PatternCondition();
+            PatternCondition ncondition = new PatternCondition();
             int flags = 0;
             if (isNocase()) {
                 flags |= Pattern.CASE_INSENSITIVE;
             }
-            condition.pattern = Pattern.compile(condPattern, flags);
+            ncondition.pattern = Pattern.compile(condPattern, flags);
+            this.condition = ncondition;
         }
     }
 
     public Matcher getMatcher() {
-        Object condition = this.condition.get();
         if (condition instanceof PatternCondition) {
-            return ((PatternCondition) condition).matcher;
+            return ((PatternCondition) condition).getMatcher();
         }
         return null;
     }
@@ -171,7 +181,7 @@ public class RewriteCond {
 
     protected Substitution test = null;
 
-    protected ThreadLocal<Condition> condition = new ThreadLocal<>();
+    protected Condition condition = null;
 
     /**
      * This makes the test case-insensitive, i.e., there is no difference between
@@ -196,46 +206,6 @@ public class RewriteCond {
      */
     public boolean evaluate(Matcher rule, Matcher cond, Resolver resolver) {
         String value = test.evaluate(rule, cond, resolver);
-        Condition condition = this.condition.get();
-        if (condition == null) {
-            if (condPattern.startsWith("<")) {
-                LexicalCondition ncondition = new LexicalCondition();
-                ncondition.type = -1;
-                ncondition.condition = condPattern.substring(1);
-                condition = ncondition;
-            } else if (condPattern.startsWith(">")) {
-                LexicalCondition ncondition = new LexicalCondition();
-                ncondition.type = 1;
-                ncondition.condition = condPattern.substring(1);
-                condition = ncondition;
-            } else if (condPattern.startsWith("=")) {
-                LexicalCondition ncondition = new LexicalCondition();
-                ncondition.type = 0;
-                ncondition.condition = condPattern.substring(1);
-                condition = ncondition;
-            } else if (condPattern.equals("-d")) {
-                ResourceCondition ncondition = new ResourceCondition();
-                ncondition.type = 0;
-                condition = ncondition;
-            } else if (condPattern.equals("-f")) {
-                ResourceCondition ncondition = new ResourceCondition();
-                ncondition.type = 1;
-                condition = ncondition;
-            } else if (condPattern.equals("-s")) {
-                ResourceCondition ncondition = new ResourceCondition();
-                ncondition.type = 2;
-                condition = ncondition;
-            } else {
-                PatternCondition ncondition = new PatternCondition();
-                int flags = 0;
-                if (isNocase()) {
-                    flags |= Pattern.CASE_INSENSITIVE;
-                }
-                ncondition.pattern = Pattern.compile(condPattern, flags);
-                condition = ncondition;
-            }
-            this.condition.set(condition);
-        }
         if (positive) {
             return condition.evaluate(value, resolver);
         } else {


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


[tomcat] 02/04: Align with master. Back-port i18n support.

Posted by ma...@apache.org.
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 b5c04d5e369d37599a7f9547a2eae944e8b9240d
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Jul 29 10:49:01 2019 +0100

    Align with master. Back-port i18n support.
---
 .../valves/rewrite/LocalStrings.properties         | 20 +++++++++++++++++
 .../valves/rewrite/LocalStrings_fr.properties      | 20 +++++++++++++++++
 .../valves/rewrite/LocalStrings_ja.properties      | 20 +++++++++++++++++
 .../catalina/valves/rewrite/RewriteValve.java      | 26 +++++++++++-----------
 4 files changed, 73 insertions(+), 13 deletions(-)

diff --git a/java/org/apache/catalina/valves/rewrite/LocalStrings.properties b/java/org/apache/catalina/valves/rewrite/LocalStrings.properties
new file mode 100644
index 0000000..63ecfb3
--- /dev/null
+++ b/java/org/apache/catalina/valves/rewrite/LocalStrings.properties
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+rewriteValve.closeError=Error closing configuration
+rewriteValve.invalidFlags=Invalid flag in [{0}] flags [{1}]
+rewriteValve.invalidLine=Invalid line [{0}]
+rewriteValve.invalidMapClassName=Invalid map class name [{0}]
+rewriteValve.readError=Error reading configuration
diff --git a/java/org/apache/catalina/valves/rewrite/LocalStrings_fr.properties b/java/org/apache/catalina/valves/rewrite/LocalStrings_fr.properties
new file mode 100644
index 0000000..aac8da4
--- /dev/null
+++ b/java/org/apache/catalina/valves/rewrite/LocalStrings_fr.properties
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+rewriteValve.closeError=Erreur lors de la fermeture de la configuration
+rewriteValve.invalidFlags=Indicateur invalide dans [{0}] indicateurs [{1}]
+rewriteValve.invalidLine=Ligne invalide [{0}]
+rewriteValve.invalidMapClassName=Le nom de la classe [{0}] de la structure est invalide
+rewriteValve.readError=Erreur lors de la lecture de la configuration
diff --git a/java/org/apache/catalina/valves/rewrite/LocalStrings_ja.properties b/java/org/apache/catalina/valves/rewrite/LocalStrings_ja.properties
new file mode 100644
index 0000000..88604f1
--- /dev/null
+++ b/java/org/apache/catalina/valves/rewrite/LocalStrings_ja.properties
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+rewriteValve.closeError=構成を閉じる際のエラー
+rewriteValve.invalidFlags=[{0}]に無効なフラグ [{1}]があります。
+rewriteValve.invalidLine=無効な行[{0}]
+rewriteValve.invalidMapClassName=Mapクラス名[{0}]が無効です。
+rewriteValve.readError=構成の読み取りエラー
diff --git a/java/org/apache/catalina/valves/rewrite/RewriteValve.java b/java/org/apache/catalina/valves/rewrite/RewriteValve.java
index 52996a4..284a585 100644
--- a/java/org/apache/catalina/valves/rewrite/RewriteValve.java
+++ b/java/org/apache/catalina/valves/rewrite/RewriteValve.java
@@ -188,12 +188,12 @@ public class RewriteValve extends ValveBase {
                 BufferedReader reader = new BufferedReader(isr)) {
             parse(reader);
         } catch (IOException ioe) {
-            containerLog.error("Error closing configuration", ioe);
+            containerLog.error(sm.getString("rewriteValve.closeError"), ioe);
         } finally {
             try {
                 is.close();
             } catch (IOException e) {
-                containerLog.error("Error closing configuration", e);
+                containerLog.error(sm.getString("rewriteValve.closeError"), e);
             }
         }
 
@@ -273,7 +273,7 @@ public class RewriteValve extends ValveBase {
                     }
                 }
             } catch (IOException e) {
-                containerLog.error("Error reading configuration", e);
+                containerLog.error(sm.getString("rewriteValve.readError"), e);
             }
         }
         this.rules = rules.toArray(new RewriteRule[0]);
@@ -638,7 +638,7 @@ public class RewriteValve extends ValveBase {
                 // RewriteCond TestString CondPattern [Flags]
                 RewriteCond condition = new RewriteCond();
                 if (tokenizer.countTokens() < 2) {
-                    throw new IllegalArgumentException("Invalid line: " + line);
+                    throw new IllegalArgumentException(sm.getString("rewriteValve.invalidLine", line));
                 }
                 condition.setTestString(tokenizer.nextToken());
                 condition.setCondPattern(tokenizer.nextToken());
@@ -658,7 +658,7 @@ public class RewriteValve extends ValveBase {
                 // RewriteRule Pattern Substitution [Flags]
                 RewriteRule rule = new RewriteRule();
                 if (tokenizer.countTokens() < 2) {
-                    throw new IllegalArgumentException("Invalid line: " + line);
+                    throw new IllegalArgumentException(sm.getString("rewriteValve.invalidLine", line));
                 }
                 rule.setPatternString(tokenizer.nextToken());
                 rule.setSubstitutionString(tokenizer.nextToken());
@@ -677,7 +677,7 @@ public class RewriteValve extends ValveBase {
             } else if (token.equals("RewriteMap")) {
                 // RewriteMap name rewriteMapClassName whateverOptionalParameterInWhateverFormat
                 if (tokenizer.countTokens() < 2) {
-                    throw new IllegalArgumentException("Invalid line: " + line);
+                    throw new IllegalArgumentException(sm.getString("rewriteValve.invalidLine", line));
                 }
                 String name = tokenizer.nextToken();
                 String rewriteMapClassName = tokenizer.nextToken();
@@ -686,7 +686,7 @@ public class RewriteValve extends ValveBase {
                     map = (RewriteMap) (Class.forName(
                             rewriteMapClassName).getConstructor().newInstance());
                 } catch (Exception e) {
-                    throw new IllegalArgumentException("Invalid map className: " + line);
+                    throw new IllegalArgumentException(sm.getString("rewriteValve.invalidMapClassName", line));
                 }
                 if (tokenizer.hasMoreTokens()) {
                     map.setParameters(tokenizer.nextToken());
@@ -698,7 +698,7 @@ public class RewriteValve extends ValveBase {
             } else if (token.startsWith("#")) {
                 // it's a comment, ignore it
             } else {
-                throw new IllegalArgumentException("Invalid line: " + line);
+                throw new IllegalArgumentException(sm.getString("rewriteValve.invalidLine", line));
             }
         }
         return null;
@@ -717,7 +717,7 @@ public class RewriteValve extends ValveBase {
         } else if (flag.equals("OR") || flag.equals("ornext")) {
             condition.setOrnext(true);
         } else {
-            throw new IllegalArgumentException("Invalid flag in: " + line + " flags: " + flag);
+            throw new IllegalArgumentException(sm.getString("rewriteValve.invalidFlags", line, flag));
         }
     }
 
@@ -742,7 +742,7 @@ public class RewriteValve extends ValveBase {
             }
             StringTokenizer tokenizer = new StringTokenizer(flag, ":");
             if (tokenizer.countTokens() < 2) {
-                throw new IllegalArgumentException("Invalid flag in: " + line);
+                throw new IllegalArgumentException(sm.getString("rewriteValve.invalidFlags", line, flag));
             }
             rule.setCookieName(tokenizer.nextToken());
             rule.setCookieValue(tokenizer.nextToken());
@@ -753,7 +753,7 @@ public class RewriteValve extends ValveBase {
                 try {
                     rule.setCookieLifetime(Integer.parseInt(tokenizer.nextToken()));
                 } catch (NumberFormatException e) {
-                    throw new IllegalArgumentException("Invalid flag in: " + line, e);
+                    throw new IllegalArgumentException(sm.getString("rewriteValve.invalidFlags", line, flag), e);
                 }
             }
             if (tokenizer.hasMoreTokens()) {
@@ -774,7 +774,7 @@ public class RewriteValve extends ValveBase {
             }
             int pos = flag.indexOf(':');
             if (pos == -1 || (pos + 1) == flag.length()) {
-                throw new IllegalArgumentException("Invalid flag in: " + line);
+                throw new IllegalArgumentException(sm.getString("rewriteValve.invalidFlags", line, flag));
             }
             rule.addEnvName(flag.substring(0, pos));
             rule.addEnvValue(flag.substring(pos + 1));
@@ -839,7 +839,7 @@ public class RewriteValve extends ValveBase {
             rule.setType(true);
             rule.setTypeValue(flag);
         } else {
-            throw new IllegalArgumentException("Invalid flag in: " + line + " flag: " + flag);
+            throw new IllegalArgumentException(sm.getString("rewriteValve.invalidFlags", line, flag));
         }
     }
 }


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


[tomcat] 01/04: Align with master. Back-port simple clean-up.

Posted by ma...@apache.org.
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 51f00c256a7e7f0dc0f7bf5258fb40616dce3757
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Jul 29 10:44:30 2019 +0100

    Align with master. Back-port simple clean-up.
---
 java/org/apache/catalina/valves/rewrite/RewriteRule.java  | 6 ++----
 java/org/apache/catalina/valves/rewrite/RewriteValve.java | 5 +++--
 java/org/apache/catalina/valves/rewrite/Substitution.java | 3 ++-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/catalina/valves/rewrite/RewriteRule.java b/java/org/apache/catalina/valves/rewrite/RewriteRule.java
index e6dc0fa..0bee31f 100644
--- a/java/org/apache/catalina/valves/rewrite/RewriteRule.java
+++ b/java/org/apache/catalina/valves/rewrite/RewriteRule.java
@@ -17,6 +17,7 @@
 package org.apache.catalina.valves.rewrite;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -68,10 +69,7 @@ public class RewriteRule {
     }
 
     public void addCondition(RewriteCond condition) {
-        RewriteCond[] conditions = new RewriteCond[this.conditions.length + 1];
-        for (int i = 0; i < this.conditions.length; i++) {
-            conditions[i] = this.conditions[i];
-        }
+        RewriteCond[] conditions = Arrays.copyOf(this.conditions, this.conditions.length + 1);
         conditions[this.conditions.length] = condition;
         this.conditions = conditions;
     }
diff --git a/java/org/apache/catalina/valves/rewrite/RewriteValve.java b/java/org/apache/catalina/valves/rewrite/RewriteValve.java
index 220aa60..52996a4 100644
--- a/java/org/apache/catalina/valves/rewrite/RewriteValve.java
+++ b/java/org/apache/catalina/valves/rewrite/RewriteValve.java
@@ -27,6 +27,7 @@ import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Hashtable;
+import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
 
@@ -225,8 +226,8 @@ public class RewriteValve extends ValveBase {
     }
 
     protected void parse(BufferedReader reader) throws LifecycleException {
-        ArrayList<RewriteRule> rules = new ArrayList<>();
-        ArrayList<RewriteCond> conditions = new ArrayList<>();
+        List<RewriteRule> rules = new ArrayList<>();
+        List<RewriteCond> conditions = new ArrayList<>();
         while (true) {
             try {
                 String line = reader.readLine();
diff --git a/java/org/apache/catalina/valves/rewrite/Substitution.java b/java/org/apache/catalina/valves/rewrite/Substitution.java
index 4cd2aec..58ad20e 100644
--- a/java/org/apache/catalina/valves/rewrite/Substitution.java
+++ b/java/org/apache/catalina/valves/rewrite/Substitution.java
@@ -17,6 +17,7 @@
 package org.apache.catalina.valves.rewrite;
 
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
 
@@ -129,7 +130,7 @@ public class Substitution {
 
     private SubstitutionElement[] parseSubtitution(String sub, Map<String, RewriteMap> maps) {
 
-        ArrayList<SubstitutionElement> elements = new ArrayList<>();
+        List<SubstitutionElement> elements = new ArrayList<>();
         int pos = 0;
         int percentPos = 0;
         int dollarPos = 0;


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


[tomcat] 04/04: Address a few more SpotBugs warnings

Posted by ma...@apache.org.
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 4fa6a00a582ed6726451e71ac8f76e868631cb98
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Dec 1 20:35:35 2017 +0000

    Address a few more SpotBugs warnings
---
 java/org/apache/catalina/startup/ExpandWar.java           | 13 ++++++++++---
 java/org/apache/catalina/startup/LocalStrings.properties  |  3 +++
 java/org/apache/catalina/startup/Tomcat.java              |  5 ++++-
 java/org/apache/catalina/util/URLEncoder.java             |  2 +-
 java/org/apache/catalina/valves/rewrite/RewriteValve.java |  8 ++++----
 java/org/apache/el/stream/StreamELResolverImpl.java       |  7 ++++++-
 res/findbugs/filter-false-positives.xml                   | 12 ++++++++++++
 7 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/java/org/apache/catalina/startup/ExpandWar.java b/java/org/apache/catalina/startup/ExpandWar.java
index 053464f..7fd7144 100644
--- a/java/org/apache/catalina/startup/ExpandWar.java
+++ b/java/org/apache/catalina/startup/ExpandWar.java
@@ -166,15 +166,22 @@ public class ExpandWar {
                     expand(input, expandedFile);
                     long lastModified = jarEntry.getTime();
                     if ((lastModified != -1) && (lastModified != 0)) {
-                        expandedFile.setLastModified(lastModified);
+                        if (!expandedFile.setLastModified(lastModified)) {
+                            throw new IOException(
+                                    sm.getString("expandWar.lastModifiedFailed", expandedFile));
+                        }
                     }
                 }
             }
 
             // Create the warTracker file and align the last modified time
             // with the last modified time of the WAR
-            warTracker.createNewFile();
-            warTracker.setLastModified(warLastModified);
+            if (!warTracker.createNewFile()) {
+                throw new IOException(sm.getString("expandWar.createFileFailed", warTracker));
+            }
+            if (!warTracker.setLastModified(warLastModified)) {
+                throw new IOException(sm.getString("expandWar.lastModifiedFailed", warTracker));
+            }
 
             success = true;
         } catch (IOException e) {
diff --git a/java/org/apache/catalina/startup/LocalStrings.properties b/java/org/apache/catalina/startup/LocalStrings.properties
index a55f45d..8b1a617 100644
--- a/java/org/apache/catalina/startup/LocalStrings.properties
+++ b/java/org/apache/catalina/startup/LocalStrings.properties
@@ -87,9 +87,11 @@ engineConfig.stop=EngineConfig: Processing STOP
 
 expandWar.copy=Error copying [{0}] to [{1}]
 expandWar.createFailed=Unable to create the directory [{0}]
+expandWar.createFileFailed=Unable to create the file [{0}]
 expandWar.deleteFailed=[{0}] could not be completely deleted. The presence of the remaining files may cause problems
 expandWar.deleteOld=An expanded directory [{0}] was found with a last modified time that did not match the associated WAR. It will be deleted.
 expandWar.illegalPath=The archive [{0}] is malformed and will be ignored: an entry contains an illegal path [{1}] which was not expanded to [{2}] since that is outside of the defined docBase [{3}]
+expandWar.lastModifiedFailed=Unable to set the last modified time for [{0}]
 expandWar.missingJarEntry=Cannot get input stream for JarEntry [{0}] - broken WAR file?
 
 failedContext.start=Failed to process either the global, per-host or context-specific context.xml file therefore the [{0}] Context cannot be started.
@@ -136,6 +138,7 @@ passwdUserDatabase.readFail=Failed to obtain a complete set of users from /etc/p
 
 tomcat.addWebapp.conflictChild=Unable to deploy WAR at [{0}] to context path [{1}] because of existing context [{2}]
 tomcat.addWebapp.conflictFile=Unable to deploy WAR at [{0}] to context path [{1}] because of existing file [{2}]
+tomcat.homeDirMakeFail=Unable to create the directory [{0}] to use as the home directory
 
 userConfig.database=Exception loading user database
 userConfig.deploy=Deploying web application for user [{0}]
diff --git a/java/org/apache/catalina/startup/Tomcat.java b/java/org/apache/catalina/startup/Tomcat.java
index 5102a37..297f1f4 100644
--- a/java/org/apache/catalina/startup/Tomcat.java
+++ b/java/org/apache/catalina/startup/Tomcat.java
@@ -808,7 +808,10 @@ public class Tomcat {
             server.setCatalinaHome(baseFile);
         } else {
             File homeFile = new File(catalinaHome);
-            homeFile.mkdirs();
+            if (!homeFile.isDirectory() && !homeFile.mkdirs()) {
+                // Failed to create home directory
+                throw new IllegalStateException(sm.getString("tomcat.homeDirMakeFail", homeFile));
+            }
             try {
                 homeFile = homeFile.getCanonicalFile();
             } catch (IOException e) {
diff --git a/java/org/apache/catalina/util/URLEncoder.java b/java/org/apache/catalina/util/URLEncoder.java
index e1ecfc4..5f630e0 100644
--- a/java/org/apache/catalina/util/URLEncoder.java
+++ b/java/org/apache/catalina/util/URLEncoder.java
@@ -37,7 +37,7 @@ import org.apache.tomcat.util.buf.B2CConverter;
  * @author Craig R. McClanahan
  * @author Remy Maucherat
  */
-public class URLEncoder implements Cloneable {
+public final class URLEncoder implements Cloneable {
 
     private static final char[] hexadecimal =
             {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
diff --git a/java/org/apache/catalina/valves/rewrite/RewriteValve.java b/java/org/apache/catalina/valves/rewrite/RewriteValve.java
index 284a585..5b719ba 100644
--- a/java/org/apache/catalina/valves/rewrite/RewriteValve.java
+++ b/java/org/apache/catalina/valves/rewrite/RewriteValve.java
@@ -554,18 +554,18 @@ public class RewriteValve extends ValveBase {
                     }
                     request.getMappingData().recycle();
                     // Reinvoke the whole request recursively
+                    Connector connector = request.getConnector();
                     try {
-                        Connector connector = request.getConnector();
                         if (!connector.getProtocolHandler().getAdapter().prepare(
                                 request.getCoyoteRequest(), response.getCoyoteResponse())) {
                             return;
                         }
-                        Pipeline pipeline = connector.getService().getContainer().getPipeline();
-                        request.setAsyncSupported(pipeline.isAsyncSupported());
-                        pipeline.getFirst().invoke(request, response);
                     } catch (Exception e) {
                         // This doesn't actually happen in the Catalina adapter implementation
                     }
+                    Pipeline pipeline = connector.getService().getContainer().getPipeline();
+                    request.setAsyncSupported(pipeline.isAsyncSupported());
+                    pipeline.getFirst().invoke(request, response);
                 }
             } else {
                 getNext().invoke(request, response);
diff --git a/java/org/apache/el/stream/StreamELResolverImpl.java b/java/org/apache/el/stream/StreamELResolverImpl.java
index d76dd7e..f5f6bcf 100644
--- a/java/org/apache/el/stream/StreamELResolverImpl.java
+++ b/java/org/apache/el/stream/StreamELResolverImpl.java
@@ -20,6 +20,7 @@ import java.beans.FeatureDescriptor;
 import java.lang.reflect.Array;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 import javax.el.ELContext;
 import javax.el.ELResolver;
@@ -97,7 +98,11 @@ public class StreamELResolverImpl extends ELResolver {
 
         @Override
         public Object next() {
-            return Array.get(base, index++);
+            try {
+                return Array.get(base, index++);
+            } catch (ArrayIndexOutOfBoundsException e) {
+                throw new NoSuchElementException();
+            }
         }
 
         @Override
diff --git a/res/findbugs/filter-false-positives.xml b/res/findbugs/filter-false-positives.xml
index d8bed9f..f441fdf 100644
--- a/res/findbugs/filter-false-positives.xml
+++ b/res/findbugs/filter-false-positives.xml
@@ -340,6 +340,12 @@
     <Bug code="Dm" />
   </Match>
   <Match>
+    <!-- Failure at this point is fatal -->
+    <Class name="org.apache.catalina.startup.Bootstrap" />
+    <Method name="initClassLoaders" />
+    <Bug pattern="DM_EXIT" />
+  </Match>
+  <Match>
     <!-- Catalina isn't used when embedding -->
     <Class name="org.apache.catalina.startup.Catalina" />
     <Method name="stopServer" />
@@ -355,6 +361,12 @@
     <Bug code="OBL" />
   </Match>
   <Match>
+    <!-- Method checks result and logs error later -->
+    <Class name="org.apache.catalina.startup.ExpandWar" />
+    <Method name="deleteDir" />
+    <Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE" />
+  </Match>
+  <Match>
     <!-- Sleep is short, needs to keep lock -->
     <Class name="org.apache.catalina.startup.HostConfig" />
     <Method name="checkResources" />


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