You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by kw...@apache.org on 2022/02/15 12:03:40 UTC
[jackrabbit-filevault] 02/02: releng: fix remaining SonarQube issues
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git
commit fcab5d786794ec5de637c19e03d5a64f473b6144
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Tue Feb 15 11:49:02 2022 +0100
releng: fix remaining SonarQube issues
---
.../apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java | 11 ++++++-----
.../org/apache/jackrabbit/vault/util/DocViewProperty2.java | 2 +-
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java
index 752567e..98e7663 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewImporter.java
@@ -1163,11 +1163,12 @@ public class DocViewImporter implements DocViewParserHandler {
return effectiveNodeType.getApplicablePropertyDefinition(npResolver.getJCRName(docViewProperty.getName()), docViewProperty.isMultiValue(), docViewProperty.getType()).map(PropertyDefinition::isProtected).orElse(false);
}
- private Node getNodeByIdOrName(@NotNull Node currentNode, @NotNull DocViewNode2 ni, boolean isUuidNewlyAssigned) throws RepositoryException {
+ private Node getNodeByIdOrName(@NotNull Node currentNode, @NotNull DocViewNode2 ni, boolean isIdNewlyAssigned) throws RepositoryException {
Node node = null;
- if (ni.getIdentifier().isPresent() && !isUuidNewlyAssigned) {
+ Optional<String> id = ni.getIdentifier();
+ if (id.isPresent() && !isIdNewlyAssigned) {
try {
- node = currentNode.getSession().getNodeByIdentifier(ni.getIdentifier().get());
+ node = currentNode.getSession().getNodeByIdentifier(id.get());
} catch (RepositoryException e) {
log.warn("Newly created node not found by uuid {}: {}", currentNode.getPath() + "/" + ni.getName(), e.toString());
}
@@ -1183,7 +1184,7 @@ public class DocViewImporter implements DocViewParserHandler {
try {
node = currentNode.getNode(ni.getName().toString());
} catch (RepositoryException e) {
- log.warn("Newly created node not found by name {}: {}", currentNode.getPath() + "/" + ni.getName(), e.toString());
+ log.debug("Newly created node not found by name {}: {}", currentNode.getPath() + "/" + ni.getName(), e.toString());
throw e;
}
}
@@ -1283,7 +1284,7 @@ public class DocViewImporter implements DocViewParserHandler {
*/
private DocViewAdapter adapter;
- public StackElement(@NotNull Node node, boolean isNew) throws RepositoryException {
+ public StackElement(@Nullable Node node, boolean isNew) throws RepositoryException {
this.node = node;
this.isNew = isNew;
isCheckedOut = node == null || !node.isNodeType(JcrConstants.MIX_VERSIONABLE) || node.isCheckedOut();
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/util/DocViewProperty2.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/util/DocViewProperty2.java
index 36f4695..faaceba 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/util/DocViewProperty2.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/util/DocViewProperty2.java
@@ -582,7 +582,7 @@ public class DocViewProperty2 {
Value binaryValue = node.getSession().getValueFactory().createValue(ref);
binaryValues.add(binaryValue);
// compare with existing value
- if (!modified && n < existingValues.length && existingValues[n] != null) {
+ if (!modified && existingValues != null && n < existingValues.length && existingValues[n] != null) {
Binary existingBinary = existingValues[0].getBinary();
if (!existingBinary.equals(binaryValue.getBinary())) {
modified = true;