Github user manishgupta88 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2525#discussion_r203991119
--- Diff:
core/src/main/java/org/apache/carbondata/core/datastore/filesystem/LocalCarbonFile.java
---
@@ -375,7 +381,15 @@ public DataOutputStream getDataOutputStream(String
path, FileFactory.FileType fi
} else if ("ZSTD".equalsIgnoreCase(compressor)) {
// compression level 1 is cost-effective for sort temp file
// which is not used for storage
- outputStream = new ZstdOutputStream(new FileOutputStream(path), 1);
+ FileOutputStream fileOutputStream = new FileOutputStream(path);
+ try {
+ outputStream = (OutputStream)
Class.forName("com.github.luben.zstd.ZstdOutputStream")
+ .getConstructor(OutputStream.class,
int.class).newInstance(fileOutputStream, 1);
+ } catch (ReflectiveOperationException e) {
+ throw new IOException(e);
+ } finally {
+ fileOutputStream.close();
--- End diff --
dont close the stream here....it should be closed by the caller after its
usage is complete
Only in case of failure you close in catch block and catch for
Throwable...same comment is applicable for above code changes also..
---