You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by jo...@apache.org on 2026/01/26 17:57:36 UTC
(jackrabbit-filevault) branch JCRVLT-838 updated: JCRVLT-838 add guard to prevent NPE
This is an automated email from the ASF dual-hosted git repository.
joerghoh pushed a commit to branch JCRVLT-838
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git
The following commit(s) were added to refs/heads/JCRVLT-838 by this push:
new 503494c9 JCRVLT-838 add guard to prevent NPE
503494c9 is described below
commit 503494c9edb1ff3b87561483eb2f76f8d1959bb2
Author: Joerg Hoh <jh...@adobe.com>
AuthorDate: Mon Jan 26 18:57:26 2026 +0100
JCRVLT-838 add guard to prevent NPE
---
.../src/main/java/org/apache/jackrabbit/vault/fs/io/ZipArchive.java | 4 +++-
.../main/java/org/apache/jackrabbit/vault/fs/io/ZipNioArchive.java | 4 +++-
.../org/apache/jackrabbit/vault/packaging/impl/ZipVaultPackage.java | 1 +
.../java/org/apache/jackrabbit/vault/fs/io/ZipArchiveCloseTest.java | 6 +++---
4 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/ZipArchive.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/ZipArchive.java
index 300af64e..1543a2cd 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/ZipArchive.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/ZipArchive.java
@@ -223,7 +223,9 @@ public class ZipArchive extends AbstractArchive {
if (jar != null) {
jar.close();
jar = null;
- CloseWatcher.unregister(watcher);
+ if (watcher != null) {
+ CloseWatcher.unregister(watcher);
+ }
}
if (file != null && isTempFile) {
FileUtils.deleteQuietly(file);
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/ZipNioArchive.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/ZipNioArchive.java
index fe1577d2..f3a1b6ff 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/ZipNioArchive.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/ZipNioArchive.java
@@ -200,7 +200,9 @@ public class ZipNioArchive extends AbstractArchive {
@Override
public void close() {
if (zipFileSystem != null) {
- CloseWatcher.unregister(watcher);
+ if (watcher != null) {
+ CloseWatcher.unregister(watcher);
+ }
try {
zipFileSystem.close();
} catch (IOException e) {
diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/ZipVaultPackage.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/ZipVaultPackage.java
index 4a23c6ff..28a16ccc 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/ZipVaultPackage.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/ZipVaultPackage.java
@@ -149,6 +149,7 @@ public class ZipVaultPackage extends PackagePropertiesImpl implements VaultPacka
try {
return getArchive().getMetaInf();
} catch (Exception e) {
+ log.warn("Failed to read meta information:", e);
return null;
}
}
diff --git a/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/io/ZipArchiveCloseTest.java b/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/io/ZipArchiveCloseTest.java
index 07eceeda..3ee40ed8 100644
--- a/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/io/ZipArchiveCloseTest.java
+++ b/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/io/ZipArchiveCloseTest.java
@@ -94,7 +94,7 @@ public class ZipArchiveCloseTest {
* Test demonstrating the exact bug from the stack trace by following
* the exact call chain from JcrPackageManagerImpl.assemble().
*/
- @Test(expected = NullPointerException.class)
+ @Test
public void testExactCallChainFromAssemble() throws IOException {
File zipFile = createZipWithMalformedProperties();
@@ -116,7 +116,7 @@ public class ZipArchiveCloseTest {
/**
* Simpler test showing the same bug at the ZipArchive level directly.
*/
- @Test(expected = NullPointerException.class)
+ @Test
public void testCloseAfterPartiallyFailedOpen() throws IOException {
File zipFile = createZipWithMalformedProperties();
ZipArchive archive = new ZipArchive(zipFile, false);
@@ -136,7 +136,7 @@ public class ZipArchiveCloseTest {
* Test demonstrating that subsequent open() calls don't fix the problem.
*
*/
- @Test(expected = NullPointerException.class)
+ @Test
public void testSecondOpenDoesNotFixWatcher() throws IOException {
File zipFile = createZipWithMalformedProperties();
ZipArchive archive = new ZipArchive(zipFile, false);