sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefane...@apache.org
Subject svn commit: r1651360 - /sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/MockedResource.java
Date Tue, 13 Jan 2015 14:36:52 GMT
Author: stefanegli
Date: Tue Jan 13 14:36:52 2015
New Revision: 1651360

URL: http://svn.apache.org/r1651360
Log:
SLING-4303 : avoiding a NPE plus more logging added for an error case

Modified:
    sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/MockedResource.java

Modified: sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/MockedResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/MockedResource.java?rev=1651360&r1=1651359&r2=1651360&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/MockedResource.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/test/java/org/apache/sling/discovery/impl/setup/MockedResource.java
Tue Jan 13 14:36:52 2015
@@ -37,9 +37,13 @@ import org.apache.sling.api.resource.Mod
 import org.apache.sling.api.resource.SyntheticResource;
 import org.apache.sling.api.resource.ValueMap;
 import org.apache.sling.api.wrappers.ValueMapDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class MockedResource extends SyntheticResource {
 
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
     private final MockedResourceResolver mockedResourceResolver;
     private Session session;
 
@@ -88,6 +92,7 @@ public class MockedResource extends Synt
             try {
                 return (AdapterType) getSession().getNode(getPath());
             } catch (Exception e) {
+                logger.error("Exception occurred: "+e, e);
                 throw new RuntimeException("Exception occurred: " + e, e);
             }
         } else if (type.equals(ValueMap.class)) {
@@ -254,6 +259,9 @@ public class MockedResource extends Synt
                         if (node==null) {
                         	return null;
                         }
+                        if (!node.hasProperty(name)) {
+                            return null;
+                        }
                         Property p = node.getProperty(name);
                         if (p==null) {
                         	return null;



Mime
View raw message