Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=46986
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 8 Apr 2009 15:25:05 +0000 (15:25 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 8 Apr 2009 15:25:05 +0000 (15:25 +0000)
Find bugs was complaining although these have not been reported as causing issues for any users.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@763281 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jasper/Constants.java
java/org/apache/jasper/compiler/PageInfo.java
java/org/apache/jasper/xmlparser/ParserUtils.java

index 66de25d..90db003 100644 (file)
 
 package org.apache.jasper;
 
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
 
 /**
  * Some constants and other global data that are used by the compiler and the runtime.
@@ -51,11 +55,13 @@ public class Constants {
      * These classes/packages are automatically imported by the
      * generated code. 
      */
-    public static final String[] STANDARD_IMPORTS = { 
+    private static final String[] PRIVATE_STANDARD_IMPORTS = { 
        "javax.servlet.*", 
        "javax.servlet.http.*", 
        "javax.servlet.jsp.*"
     };
+    public static final List<String> STANDARD_IMPORTS =
+        Collections.unmodifiableList(Arrays.asList(PRIVATE_STANDARD_IMPORTS));
 
     /**
      * ServletContext attribute for classpath. This is tomcat specific. 
@@ -152,18 +158,25 @@ public class Constants {
      * an EntityResolver to return the location of the
      * cached copy of a DTD.
      */
-    public static final String[] CACHED_DTD_PUBLIC_IDS = {
+    // TODO Add 2.4, 2.5, 3.0
+    private static final String[] PRIVATE_CACHED_DTD_PUBLIC_IDS = {
        TAGLIB_DTD_PUBLIC_ID_11,
        TAGLIB_DTD_PUBLIC_ID_12,
        WEBAPP_DTD_PUBLIC_ID_22,
        WEBAPP_DTD_PUBLIC_ID_23,
     };
-    public static final String[] CACHED_DTD_RESOURCE_PATHS = {
+    public static final List<String> CACHED_DTD_PUBLIC_IDS =
+        Collections.unmodifiableList(
+                Arrays.asList(PRIVATE_CACHED_DTD_PUBLIC_IDS));
+    private static final String[] PRIVATE_CACHED_DTD_RESOURCE_PATHS = {
        TAGLIB_DTD_RESOURCE_PATH_11,
        TAGLIB_DTD_RESOURCE_PATH_12,
        WEBAPP_DTD_RESOURCE_PATH_22,
        WEBAPP_DTD_RESOURCE_PATH_23,
     };
+    public static final List<String> CACHED_DTD_RESOURCE_PATHS =
+        Collections.unmodifiableList(
+                Arrays.asList(PRIVATE_CACHED_DTD_RESOURCE_PATHS));
     
     /**
      * Default URLs to download the pluging for Netscape and IE.
index 70b30d7..84fba8a 100644 (file)
@@ -110,8 +110,7 @@ class PageInfo {
         this.prefixes = new HashSet<String>();
 
         // Enter standard imports
-        for(int i = 0; i < Constants.STANDARD_IMPORTS.length; i++)
-            imports.add(Constants.STANDARD_IMPORTS[i]);
+        imports.addAll(Constants.STANDARD_IMPORTS);
     }
 
     /**
index 7f9a71f..661ae5a 100644 (file)
@@ -193,10 +193,11 @@ class MyEntityResolver implements EntityResolver {
 
     public InputSource resolveEntity(String publicId, String systemId)
             throws SAXException {
-        for (int i = 0; i < Constants.CACHED_DTD_PUBLIC_IDS.length; i++) {
-            String cachedDtdPublicId = Constants.CACHED_DTD_PUBLIC_IDS[i];
+        for (int i = 0; i < Constants.CACHED_DTD_PUBLIC_IDS.size(); i++) {
+            String cachedDtdPublicId = Constants.CACHED_DTD_PUBLIC_IDS.get(i);
             if (cachedDtdPublicId.equals(publicId)) {
-                String resourcePath = Constants.CACHED_DTD_RESOURCE_PATHS[i];
+                String resourcePath =
+                    Constants.CACHED_DTD_RESOURCE_PATHS.get(i);
                 InputStream input = this.getClass().getResourceAsStream(
                         resourcePath);
                 if (input == null) {