You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by re...@apache.org on 2024/10/03 17:52:20 UTC
(jackrabbit) branch trunk updated: JCR-5107: DbInputStream makes incorrect assumptions about commons-io internals
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit.git
The following commit(s) were added to refs/heads/trunk by this push:
new 577da037c JCR-5107: DbInputStream makes incorrect assumptions about commons-io internals
577da037c is described below
commit 577da037c0014d0ae024510cc15be70aaed56d0f
Author: Julian Reschke <ju...@gmx.de>
AuthorDate: Thu Oct 3 18:52:12 2024 +0100
JCR-5107: DbInputStream makes incorrect assumptions about commons-io internals
---
.../org/apache/jackrabbit/core/data/db/DbInputStream.java | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/db/DbInputStream.java b/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/db/DbInputStream.java
index 3bc2f0c50..99a482c57 100644
--- a/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/db/DbInputStream.java
+++ b/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/db/DbInputStream.java
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.core.data.db;
import java.io.EOFException;
import java.io.IOException;
+import java.io.InputStream;
import java.sql.ResultSet;
import org.apache.commons.io.input.AutoCloseInputStream;
@@ -40,6 +41,7 @@ public class DbInputStream extends AutoCloseInputStream {
protected boolean endOfStream;
protected ResultSet rs;
+ private InputStream initialStream;
/**
* Create a database input stream for the given identifier.
@@ -52,6 +54,7 @@ public class DbInputStream extends AutoCloseInputStream {
super(null);
this.store = store;
this.identifier = identifier;
+ this.initialStream = super.in;
}
/**
@@ -63,13 +66,11 @@ public class DbInputStream extends AutoCloseInputStream {
if (endOfStream) {
throw new EOFException();
}
- if (in == null) {
+ if (in == initialStream) {
try {
in = store.openStream(this, identifier);
} catch (DataStoreException e) {
- IOException e2 = new IOException(e.getMessage());
- e2.initCause(e);
- throw e2;
+ throw new IOException(e.getMessage(), e);
}
}
}
@@ -121,9 +122,9 @@ public class DbInputStream extends AutoCloseInputStream {
* When the stream is consumed, the database objects held by the instance are closed.
*/
public void close() throws IOException {
- if (in != null) {
+ if (in != initialStream) {
in.close();
- in = null;
+ in = initialStream;
// some additional database objects
// may need to be closed
if (rs != null) {