Fix "potential null pointer access warning".
authorkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 4 Jul 2011 13:34:48 +0000 (13:34 +0000)
committerkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 4 Jul 2011 13:34:48 +0000 (13:34 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1142659 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/util/DOMWriter.java

index caa1399..31b9fa1 100644 (file)
@@ -250,8 +250,11 @@ public class DOMWriter {
 
    /** Returns a sorted list of attributes. */
    protected Attr[] sortAttributes(NamedNodeMap attrs) {
+      if (attrs == null) {
+         return new Attr[0];
+      }
 
-      int len = (attrs != null) ? attrs.getLength() : 0;
+      int len = attrs.getLength();
       Attr array[] = new Attr[len];
       for ( int i = 0; i < len; i++ ) {
          array[i] = (Attr)attrs.item(i);