Fix some false npe warnings
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 6 Aug 2011 20:28:35 +0000 (20:28 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 6 Aug 2011 20:28:35 +0000 (20:28 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1154579 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jasper/compiler/JspUtil.java
java/org/apache/jasper/compiler/PageDataImpl.java
java/org/apache/jasper/compiler/Validator.java

index 822a134..1383f16 100644 (file)
@@ -119,6 +119,7 @@ public class JspUtil {
         int tempLength = (attrs == null) ? 0 : attrs.getLength();
         Vector<String> temp = new Vector<String>(tempLength, 1);
         for (int i = 0; i < tempLength; i++) {
+            @SuppressWarnings("null")  // If attrs==null, tempLength == 0
             String qName = attrs.getQName(i);
             if ((!qName.equals("xmlns")) && (!qName.startsWith("xmlns:")))
                 temp.addElement(qName);
index 97ce4ca..665d743 100644 (file)
@@ -510,6 +510,7 @@ class PageDataImpl extends PageData implements TagConstants {
             Attributes attrs = n.getAttributes();
             int len = (attrs == null) ? 0 : attrs.getLength();
             for (int i=0; i<len; i++) {
+                @SuppressWarnings("null")  // If attrs==null, len == 0
                 String attrName = attrs.getQName(i);
                 if (!"pageEncoding".equals(attrName)
                         && !"contentType".equals(attrName)) {
@@ -530,6 +531,7 @@ class PageDataImpl extends PageData implements TagConstants {
 
             // append remaining attributes
             for (int i=0; i<len; i++) {
+                @SuppressWarnings("null")  // If attrs==null, len == 0
                 String attrName = attrs.getQName(i);
                 if ("import".equals(attrName) || "contentType".equals(attrName)
                         || "pageEncoding".equals(attrName)) {
@@ -601,6 +603,7 @@ class PageDataImpl extends PageData implements TagConstants {
             Attributes attrs = n.getAttributes();
             int len = (attrs == null) ? 0 : attrs.getLength();
             for (int i=0; i<len; i++) {
+                @SuppressWarnings("null")  // If attrs==null, len == 0
                 String attrName = attrs.getQName(i);
                 if (!"pageEncoding".equals(attrName)) {
                     append = true;
@@ -696,6 +699,7 @@ class PageDataImpl extends PageData implements TagConstants {
             Attributes attrs = n.getTaglibAttributes();
             int len = (attrs == null) ? 0 : attrs.getLength();
             for (int i=0; i<len; i++) {
+                @SuppressWarnings("null")  // If attrs==null, len == 0
                 String name = attrs.getQName(i);
                 String value = attrs.getValue(i);
                 buf.append("  ").append(name).append("=\"").append(value).append("\"\n");
@@ -708,6 +712,7 @@ class PageDataImpl extends PageData implements TagConstants {
             len = (attrs == null) ? 0 : attrs.getLength();
             boolean defaultNSSeen = false;
             for (int i=0; i<len; i++) {
+                @SuppressWarnings("null")  // If attrs==null, len == 0
                 String name = attrs.getQName(i);
                 String value = attrs.getValue(i);
                 buf.append("  ").append(name).append("=\"").append(value).append("\"\n");
@@ -724,6 +729,7 @@ class PageDataImpl extends PageData implements TagConstants {
             attrs = n.getAttributes();
             len = (attrs == null) ? 0 : attrs.getLength();
             for (int i=0; i<len; i++) {
+                @SuppressWarnings("null")  // If attrs==null, len == 0
                 String name = attrs.getQName(i);
                 String value = attrs.getValue(i);
                 buf.append("  ").append(name).append("=\"");
index 6d68d3b..ce6ee9f 100644 (file)
@@ -896,6 +896,7 @@ class Validator {
             if (attrs == null) {
                 err.jspError(n, "jsp.error.jspelement.missing.name");
             }
+            @SuppressWarnings("null") // Exception will have been thrown above
             int xmlAttrLen = attrs.getLength();
 
             Node.Nodes namedAttrs = n.getNamedAttributeNodes();