Skip to content

Commit 28f9395

Browse files
author
Charles Greer
committed
issue #89 close input streams
1 parent bb1d3bc commit 28f9395

File tree

12 files changed

+114
-19
lines changed

12 files changed

+114
-19
lines changed

src/main/java/com/marklogic/client/extra/dom4j/DOM4JHandle.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,14 @@ protected void receiveContent(InputStream content) {
222222
throw new MarkLogicIOException(e);
223223
} catch (DocumentException e) {
224224
throw new MarkLogicIOException(e);
225+
} finally {
226+
try {
227+
content.close();
228+
} catch (IOException e) {
229+
// ignore.
230+
}
225231
}
232+
226233
}
227234

228235
@Override

src/main/java/com/marklogic/client/extra/gson/GSONHandle.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.marklogic.client.extra.gson;
1717

1818
import java.io.ByteArrayInputStream;
19+
import java.io.IOException;
1920
import java.io.InputStream;
2021
import java.io.InputStreamReader;
2122
import java.io.UnsupportedEncodingException;
@@ -182,8 +183,15 @@ protected void receiveContent(InputStream content) {
182183
throw new MarkLogicIOException(e);
183184
} catch (UnsupportedEncodingException e) {
184185
throw new MarkLogicIOException(e);
186+
} finally {
187+
try {
188+
content.close();
189+
} catch (IOException e) {
190+
// ignore.
191+
}
185192
}
186193

194+
187195
}
188196
@Override
189197
protected String sendContent() {

src/main/java/com/marklogic/client/extra/jackson/JacksonHandle.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ protected void receiveContent(InputStream content) {
197197
throw new MarkLogicIOException(e);
198198
} catch (IOException e) {
199199
throw new MarkLogicIOException(e);
200+
} finally {
201+
try {
202+
content.close();
203+
} catch (IOException e) {
204+
// ignore.
205+
}
200206
}
201207

202208
}

src/main/java/com/marklogic/client/extra/jdom/JDOMHandle.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ protected void receiveContent(InputStream content) {
223223
throw new MarkLogicIOException(e);
224224
} catch (IOException e) {
225225
throw new MarkLogicIOException(e);
226+
} finally {
227+
try {
228+
content.close();
229+
} catch (IOException e) {
230+
// ignore.
231+
}
226232
}
227233
}
228234

src/main/java/com/marklogic/client/extra/xom/XOMHandle.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ protected void receiveContent(InputStream content) {
203203
throw new MarkLogicIOException(e);
204204
} catch (IOException e) {
205205
throw new MarkLogicIOException(e);
206+
} finally {
207+
try {
208+
content.close();
209+
} catch (IOException e) {
210+
// ignore.
211+
}
206212
}
207213
}
208214

src/main/java/com/marklogic/client/io/DOMHandle.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,13 +389,16 @@ protected void receiveContent(InputStream content) {
389389
domInput.setByteStream(content);
390390

391391
this.content = parser.parse(domInput);
392-
content.close();
393-
} catch (IOException e) {
394-
logger.error("Failed to parse DOM document from input stream",e);
395-
throw new MarkLogicInternalException(e);
396392
} catch (ParserConfigurationException e) {
397393
logger.error("Failed to parse DOM document from input stream",e);
398394
throw new MarkLogicInternalException(e);
395+
} finally {
396+
try {
397+
content.close();
398+
} catch (IOException e) {
399+
//ignore
400+
}
401+
399402
}
400403
}
401404
@Override

src/main/java/com/marklogic/client/io/JAXBHandle.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,12 @@ protected void receiveContent(InputStream content) {
278278
} catch (UnsupportedEncodingException e) {
279279
logger.error("Failed to unmarshall object read from database document",e);
280280
throw new MarkLogicIOException(e);
281+
} finally {
282+
try {
283+
content.close();
284+
} catch (IOException e) {
285+
// ignore.
286+
}
281287
}
282288
}
283289
@Override

src/main/java/com/marklogic/client/io/QueryOptionsHandle.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,13 @@ protected void receiveContent(InputStream content) {
10381038
} catch (UnsupportedEncodingException e) {
10391039
// This can't actually happen...stupid checked exceptions
10401040
throw new MarkLogicBindingException(e);
1041-
}
1041+
} finally {
1042+
try {
1043+
content.close();
1044+
} catch (IOException e) {
1045+
// ignore.
1046+
}
1047+
}
10421048
}
10431049

10441050
protected OutputStreamSender sendContent() {

src/main/java/com/marklogic/client/io/TuplesHandle.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.marklogic.client.io;
1717

18+
import java.io.IOException;
1819
import java.io.InputStream;
1920
import java.io.InputStreamReader;
2021
import java.io.UnsupportedEncodingException;
@@ -24,19 +25,19 @@
2425
import javax.xml.bind.JAXBException;
2526
import javax.xml.bind.Unmarshaller;
2627

27-
import com.marklogic.client.query.AggregateResult;
28-
import com.marklogic.client.query.ValuesMetrics;
2928
import org.slf4j.Logger;
3029
import org.slf4j.LoggerFactory;
3130

3231
import com.marklogic.client.MarkLogicBindingException;
3332
import com.marklogic.client.MarkLogicIOException;
34-
import com.marklogic.client.query.Tuple;
3533
import com.marklogic.client.impl.TuplesBuilder;
36-
import com.marklogic.client.query.TuplesResults;
37-
import com.marklogic.client.query.ValuesDefinition;
3834
import com.marklogic.client.io.marker.OperationNotSupported;
3935
import com.marklogic.client.io.marker.TuplesReadHandle;
36+
import com.marklogic.client.query.AggregateResult;
37+
import com.marklogic.client.query.Tuple;
38+
import com.marklogic.client.query.TuplesResults;
39+
import com.marklogic.client.query.ValuesDefinition;
40+
import com.marklogic.client.query.ValuesMetrics;
4041

4142
/**
4243
* A TuplesHandle represents a set of tuples returned by a query on the server.
@@ -109,7 +110,13 @@ protected void receiveContent(InputStream content) {
109110
} catch (JAXBException e) {
110111
logger.error("Failed to unmarshall tuples",e);
111112
throw new MarkLogicIOException(e);
112-
}
113+
} finally {
114+
try {
115+
content.close();
116+
} catch (IOException e) {
117+
// ignore.
118+
}
119+
}
113120
}
114121

115122
/**

src/main/java/com/marklogic/client/io/ValuesHandle.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.marklogic.client.io;
1717

18+
import java.io.IOException;
1819
import java.io.InputStream;
1920
import java.io.InputStreamReader;
2021
import java.io.UnsupportedEncodingException;
@@ -24,19 +25,19 @@
2425
import javax.xml.bind.JAXBException;
2526
import javax.xml.bind.Unmarshaller;
2627

27-
import com.marklogic.client.query.AggregateResult;
28-
import com.marklogic.client.query.ValuesMetrics;
2928
import org.slf4j.Logger;
3029
import org.slf4j.LoggerFactory;
3130

3231
import com.marklogic.client.MarkLogicBindingException;
3332
import com.marklogic.client.MarkLogicIOException;
34-
import com.marklogic.client.query.CountedDistinctValue;
3533
import com.marklogic.client.impl.ValuesBuilder;
36-
import com.marklogic.client.query.ValuesDefinition;
37-
import com.marklogic.client.query.ValuesResults;
3834
import com.marklogic.client.io.marker.OperationNotSupported;
3935
import com.marklogic.client.io.marker.ValuesReadHandle;
36+
import com.marklogic.client.query.AggregateResult;
37+
import com.marklogic.client.query.CountedDistinctValue;
38+
import com.marklogic.client.query.ValuesDefinition;
39+
import com.marklogic.client.query.ValuesMetrics;
40+
import com.marklogic.client.query.ValuesResults;
4041

4142
/**
4243
* A ValuesHandle represents a list of values or of tuples
@@ -114,7 +115,13 @@ protected void receiveContent(InputStream content) {
114115
} catch (JAXBException e) {
115116
logger.error("Failed to unmarshall values",e);
116117
throw new MarkLogicIOException(e);
117-
}
118+
} finally {
119+
try {
120+
content.close();
121+
} catch (IOException e) {
122+
// ignore.
123+
}
124+
}
118125
}
119126

120127
/**

0 commit comments

Comments
 (0)