velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cbris...@apache.org
Subject svn commit: r1854318 - /velocity/tools/trunk/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/XmlTool.java
Date Mon, 25 Feb 2019 15:47:09 GMT
Author: cbrisson
Date: Mon Feb 25 15:47:09 2019
New Revision: 1854318

URL: http://svn.apache.org/viewvc?rev=1854318&view=rev
Log:
[tools/generic] Add missing NPE protections

Modified:
    velocity/tools/trunk/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/XmlTool.java

Modified: velocity/tools/trunk/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/XmlTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/XmlTool.java?rev=1854318&r1=1854317&r2=1854318&view=diff
==============================================================================
--- velocity/tools/trunk/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/XmlTool.java
(original)
+++ velocity/tools/trunk/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/XmlTool.java
Mon Feb 25 15:47:09 2019
@@ -468,6 +468,10 @@ public class XmlTool extends SafeConfig
         {
             return this;
         }
+        else if (isEmpty())
+        {
+            return null;
+        }
         return new XmlTool(node());
     }
 
@@ -482,6 +486,10 @@ public class XmlTool extends SafeConfig
         {
             return this;
         }
+        else if (isEmpty())
+        {
+            return null;
+        }
         return new XmlTool(nodes.get(size() - 1));
     }
 
@@ -493,7 +501,7 @@ public class XmlTool extends SafeConfig
      */
     public XmlTool get(Number n)
     {
-        if (n == null)
+        if (n == null || isEmpty())
         {
             return null;
         }
@@ -552,7 +560,7 @@ public class XmlTool extends SafeConfig
      */
     public XmlTool find(String xpath)
     {
-        if (xpath == null || xpath.length() == 0)
+        if (xpath == null || xpath.length() == 0 || isEmpty())
         {
             return null;
         }



Mime
View raw message