mirror of https://github.com/apache/druid.git
Fixed some minor potential resource leaks.
This commit is contained in:
parent
0d24df7628
commit
35f04b4df6
|
@ -67,8 +67,11 @@ public class TsvToJson
|
|||
}
|
||||
}
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(inFile), Charsets.UTF_8));
|
||||
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), Charsets.UTF_8));
|
||||
BufferedReader in = null;
|
||||
BufferedWriter out = null;
|
||||
try {
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(inFile), Charsets.UTF_8));
|
||||
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), Charsets.UTF_8));
|
||||
String line = null;
|
||||
int count = 0;
|
||||
long currTime = System.currentTimeMillis();
|
||||
|
@ -101,9 +104,15 @@ public class TsvToJson
|
|||
}
|
||||
System.out.printf("Completed %,d lines in %,d millis.%n", count, System.currentTimeMillis() - startTime);
|
||||
out.flush();
|
||||
} finally {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static interface FieldHandler
|
||||
{
|
||||
|
|
|
@ -416,9 +416,11 @@ public class IndexMerger
|
|||
long startTime = System.currentTimeMillis();
|
||||
File indexFile = new File(outDir, "index.drd");
|
||||
|
||||
FileOutputStream fileOutputStream = null;
|
||||
FileChannel channel = null;
|
||||
try {
|
||||
channel = new FileOutputStream(indexFile).getChannel();
|
||||
fileOutputStream = new FileOutputStream(indexFile);
|
||||
channel = fileOutputStream.getChannel();
|
||||
channel.write(ByteBuffer.wrap(new byte[]{IndexIO.CURRENT_VERSION_ID}));
|
||||
|
||||
GenericIndexed.fromIterable(mergedDimensions, GenericIndexed.stringStrategy).writeToChannel(channel);
|
||||
|
@ -438,6 +440,8 @@ public class IndexMerger
|
|||
finally {
|
||||
Closeables.closeQuietly(channel);
|
||||
channel = null;
|
||||
Closeables.closeQuietly(fileOutputStream);
|
||||
fileOutputStream = null;
|
||||
}
|
||||
IndexIO.checkFileSize(indexFile);
|
||||
log.info("outDir[%s] completed index.drd in %,d millis.", outDir, System.currentTimeMillis() - startTime);
|
||||
|
|
Loading…
Reference in New Issue