You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by wt...@apache.org on 2021/06/22 18:30:34 UTC

[myfaces] branch 2.2.x updated: backport MYFACES-4187 to 2.2.x

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

wtlucy pushed a commit to branch 2.2.x
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/2.2.x by this push:
     new a5937f0  backport MYFACES-4187 to 2.2.x
     new 0ebc26b  Merge pull request #210 from wtlucy/MYFACES-4187_2.2.x
a5937f0 is described below

commit a5937f0419221964f300343828c89d01fcdbaa53
Author: Bill Lucy <wt...@gmail.com>
AuthorDate: Tue Jun 22 12:48:52 2021 -0400

    backport MYFACES-4187 to 2.2.x
---
 .../apache/myfaces/application/ResourceHandlerImpl.java   |  8 +++++++-
 .../myfaces/application/ResourceHandlerImplTest.java      | 15 +++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java b/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java
index c1744af..2748ca0 100644
--- a/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java
@@ -115,10 +115,16 @@ public class ResourceHandlerImpl extends ResourceHandler
     {
         Resource resource = null;
         
-        if (resourceName == null || resourceName.length() == 0) 
+        if (resourceName == null)
+        {
+            throw new NullPointerException();
+        }
+
+        if (resourceName.length() == 0)
         {
             return null;
         }
+
         if (resourceName.charAt(0) == '/')
         {
             // If resourceName starts with '/', remove that character because it
diff --git a/impl/src/test/java/org/apache/myfaces/application/ResourceHandlerImplTest.java b/impl/src/test/java/org/apache/myfaces/application/ResourceHandlerImplTest.java
index 70dd0d6..8d5589e 100644
--- a/impl/src/test/java/org/apache/myfaces/application/ResourceHandlerImplTest.java
+++ b/impl/src/test/java/org/apache/myfaces/application/ResourceHandlerImplTest.java
@@ -221,4 +221,19 @@ public class ResourceHandlerImplTest extends AbstractJsfTestCase
         Assert.assertNull(resource.getResourceVersion());        
         Assert.assertEquals("myres.js", resource.getResourceName());
     }
+
+    @Test
+    public void testCreateResourceNullResourceName() throws Exception
+    {
+        boolean didNPEOccur = false;
+        try
+        {
+            resourceHandler.createResource(null);
+        } catch (NullPointerException e)
+        {
+            didNPEOccur = true;
+        }
+
+        Assert.assertTrue(didNPEOccur);
+    }
 }