This is an automated email from the ASF dual-hosted git repository.
mreutegg pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new 9186a659c3 OAK-9660: NullPointerException When Moving Transient node
new 22e72d6b5a Merge pull request #975 from mreutegg/OAK-9660-1
9186a659c3 is described below
commit 9186a659c34fe8e9020d3c0ed34544b1e1b1b6d0
Author: Marcel Reutegger <[email protected]>
AuthorDate: Fri Jun 9 11:01:47 2023 +0200
OAK-9660: NullPointerException When Moving Transient node
Enable test and add some additional assertion
Implement fix
---
.../test/java/org/apache/jackrabbit/oak/jcr/TransientMoveTest.java | 7 ++++---
.../apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java | 7 +++++--
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git
a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/TransientMoveTest.java
b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/TransientMoveTest.java
index 56b2cb001d..56f301a951 100644
--- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/TransientMoveTest.java
+++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/TransientMoveTest.java
@@ -26,12 +26,12 @@ import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.commons.JcrUtils;
import org.apache.jackrabbit.oak.NodeStoreFixtures;
import org.apache.jackrabbit.oak.fixture.NodeStoreFixture;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runners.Parameterized;
import static java.util.Collections.singleton;
import static
org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture.MEMORY_NS;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class TransientMoveTest extends AbstractRepositoryTest {
@@ -45,7 +45,6 @@ public class TransientMoveTest extends AbstractRepositoryTest
{
return NodeStoreFixtures.asJunitParameters(singleton(MEMORY_NS));
}
- @Ignore("OAK-9660")
@Test
public void transientMove() throws Exception {
// setup
@@ -91,7 +90,7 @@ public class TransientMoveTest extends AbstractRepositoryTest
{
// What we really want to do is copy the child, but creating a new
node with the same name is sufficient.
// In the real world, this would have content on it, so all the
properties and children would be copied - for testing it doesn't matter.
// JcrUtil.copy(child, parent, "child", false);
- parent.addNode(child.getName(),
child.getPrimaryNodeType().getName());
+ Node c = parent.addNode(child.getName(),
child.getPrimaryNodeType().getName());
assertTrue(session.hasPendingChanges()); // None of these changes
have been persisted yet. This is to verify that no auto-saves have occurred.
@@ -99,6 +98,8 @@ public class TransientMoveTest extends AbstractRepositoryTest
{
session.move("/var/oak-bug/test/parent/child",
"/var/oak-bug/test/parent/tmp-4321"); // NPE On this Call.
session.save();
+
+ assertEquals("/var/oak-bug/test/parent/tmp-4321", c.getPath());
} finally {
session.logout();
}
diff --git
a/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
b/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
index eb7ab76534..07fb32fdf8 100644
---
a/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
+++
b/oak-store-spi/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
@@ -443,10 +443,13 @@ public class MemoryNodeBuilder implements NodeBuilder {
PropertyState head =
builder.getNodeState().getProperty(MoveDetector.SOURCE_PATH);
if (Objects.equal(base, head)) {
// Both null: no source path annotation
- // Both non null but equals: source path annotation is from a
previous commit
+ // Both non-null but equals: source path annotation is from a
previous commit
return null;
} else {
- return head.getValue(Type.STRING);
+ // OAK-9660: base may have a source path and head does not.
+ // happens when this node had a source path and was transiently
+ // removed and added again (without source path).
+ return head != null ? head.getValue(Type.STRING) : null;
}
}