Skip to content

Commit 1e91318

Browse files
committed
[bugfix] Don't destroy a BinaryValue if it is within a Map or Array in the returned Context Sequence (i.e. still in-scope)
1 parent eb580a2 commit 1e91318

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

exist-core/src/main/java/org/exist/xquery/value/BinaryValueFromFile.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ public Object toJavaObject() throws XPathException {
146146
@Override
147147
public void destroy(final XQueryContext context, final Sequence contextSequence) {
148148
// do not close if this object is part of the contextSequence
149-
if (contextSequence == this ||
150-
(contextSequence instanceof ValueSequence && ((ValueSequence) contextSequence).containsValue(this))) {
149+
if (contextSequence == this || contextSequence.containsReference(this)) {
151150
return;
152151
}
153152
try {

exist-core/src/main/java/org/exist/xquery/value/BinaryValueFromInputStream.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ public void close() throws IOException {
121121
@Override
122122
public void destroy(XQueryContext context, final Sequence contextSequence) {
123123
// do not close if this object is part of the contextSequence
124-
if (contextSequence == this
125-
|| (contextSequence instanceof ValueSequence && ((ValueSequence) contextSequence).containsValue(this))) {
124+
if (contextSequence == this || contextSequence.containsReference(this)) {
126125
return;
127126
}
128127
LOG.debug("Closing input stream");

0 commit comments

Comments
 (0)