You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by an...@apache.org on 2022/07/25 16:21:06 UTC
[sling-org-apache-sling-jcr-resource] branch master updated: SLING-11482 : Redundant checks for null (#33)
This is an automated email from the ASF dual-hosted git repository.
angela pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resource.git
The following commit(s) were added to refs/heads/master by this push:
new 72c105d SLING-11482 : Redundant checks for null (#33)
72c105d is described below
commit 72c105d67adc58ef1f4d43de78815fdcebb290b5
Author: anchela <an...@adobe.com>
AuthorDate: Mon Jul 25 18:21:02 2022 +0200
SLING-11482 : Redundant checks for null (#33)
---
.../org/apache/sling/jcr/resource/internal/JcrValueMap.java | 7 -------
.../resource/internal/helper/jcr/JcrItemResourceFactory.java | 11 +----------
.../jcr/resource/internal/helper/jcr/JcrResourceProvider.java | 7 +------
3 files changed, 2 insertions(+), 23 deletions(-)
diff --git a/src/main/java/org/apache/sling/jcr/resource/internal/JcrValueMap.java b/src/main/java/org/apache/sling/jcr/resource/internal/JcrValueMap.java
index 8955971..5baed74 100644
--- a/src/main/java/org/apache/sling/jcr/resource/internal/JcrValueMap.java
+++ b/src/main/java/org/apache/sling/jcr/resource/internal/JcrValueMap.java
@@ -90,10 +90,6 @@ public class JcrValueMap implements ValueMap {
@SuppressWarnings("unchecked")
public <T> T get(final @NotNull String aKey, final @NotNull Class<T> type) {
final String key = checkKey(aKey);
- if (type == null) {
- return (T) get(key);
- }
-
final JcrPropertyMapCacheEntry entry = this.read(key);
if (entry == null) {
return null;
@@ -108,9 +104,6 @@ public class JcrValueMap implements ValueMap {
@SuppressWarnings("unchecked")
public <T> @NotNull T get(final @NotNull String aKey, final @NotNull T defaultValue) {
final String key = checkKey(aKey);
- if (defaultValue == null) {
- return (T) get(key);
- }
// special handling in case the default value implements one
// of the interface types supported by the convertToType method
diff --git a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResourceFactory.java b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResourceFactory.java
index 4e4c3e7..f5f9a99 100644
--- a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResourceFactory.java
+++ b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResourceFactory.java
@@ -74,11 +74,6 @@ public class JcrItemResourceFactory {
*/
public @Nullable JcrItemResource<?> createResource(final @NotNull ResourceResolver resourceResolver, final @NotNull String resourcePath,
final @Nullable Resource parent, final @Nullable Map<String, String> parameters) throws RepositoryException {
- if (resourcePath == null) {
- log.debug("createResource: {} maps to an empty JCR path", resourcePath);
- return null;
- }
-
final String version;
if (parameters != null && parameters.containsKey("v")) {
version = parameters.get("v");
@@ -158,11 +153,7 @@ public class JcrItemResourceFactory {
if (childNode != null) {
return childNode;
}
- Property property = NodeUtil.getPropertyOrNull(node, relPath);
- if (property != null) {
- return property;
- }
- return null;
+ return NodeUtil.getPropertyOrNull(node, relPath);
} catch (RepositoryException e) {
log.debug("getSubitem: Can't get subitem {} of {}: {}", relPath, node, e.toString());
return null;
diff --git a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
index b1a3d80..389baed 100644
--- a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
+++ b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
@@ -551,12 +551,7 @@ public class JcrResourceProvider extends ResourceProvider<JcrProviderState> {
Item item = resource.adaptTo(Item.class);
try {
if (item == null) {
- final String jcrPath = resource.getPath();
- if (jcrPath == null) {
- logger.debug("delete: {} maps to an empty JCR path", resource.getPath());
- throw new PersistenceException("Unable to delete resource", null, resource.getPath(), null);
- }
- item = getSession(ctx).getItem(jcrPath);
+ item = getSession(ctx).getItem(resource.getPath());
}
item.remove();
} catch (final RepositoryException e) {