Skip to content

Commit 9d6eb52

Browse files
committed
fix #805 - close okio.Source when we create it with a File
1 parent 8ef3535 commit 9d6eb52

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/com/marklogic/client/impl/OkHttpServices.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
import okhttp3.logging.HttpLoggingInterceptor;
102102
import okio.BufferedSink;
103103
import okio.Okio;
104+
import okio.Source;
104105
import com.burgstaller.okhttp.AuthenticationCacheInterceptor;
105106
import com.burgstaller.okhttp.CachingAuthenticatorDecorator;
106107
import com.burgstaller.okhttp.digest.CachingAuthenticator;
@@ -5305,7 +5306,9 @@ public void writeTo(BufferedSink sink) throws IOException {
53055306
if ( obj instanceof InputStream ) {
53065307
sink.writeAll(Okio.source((InputStream) obj));
53075308
} else if ( obj instanceof File ) {
5308-
sink.writeAll(Okio.source((File) obj));
5309+
try ( Source source = Okio.source((File) obj) ) {
5310+
sink.writeAll(source);
5311+
}
53095312
} else if ( obj instanceof byte[] ) {
53105313
sink.write((byte[]) obj);
53115314
} else if ( obj instanceof String) {

0 commit comments

Comments
 (0)