Change from deprecated closeQuietly to try with resources
This commit is contained in:
@@ -18,7 +18,6 @@ package com.uber.hoodie.common.table.timeline;
|
|||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
import com.uber.hoodie.common.table.HoodieTableMetaClient;
|
import com.uber.hoodie.common.table.HoodieTableMetaClient;
|
||||||
import com.uber.hoodie.common.table.HoodieTimeline;
|
import com.uber.hoodie.common.table.HoodieTimeline;
|
||||||
import com.uber.hoodie.common.util.FSUtils;
|
import com.uber.hoodie.common.util.FSUtils;
|
||||||
@@ -303,16 +302,10 @@ public class HoodieActiveTimeline extends HoodieDefaultTimeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Optional<byte[]> readDataFromPath(Path detailPath) {
|
protected Optional<byte[]> readDataFromPath(Path detailPath) {
|
||||||
FSDataInputStream is = null;
|
try (FSDataInputStream is = fs.open(detailPath)) {
|
||||||
try {
|
|
||||||
is = fs.open(detailPath);
|
|
||||||
return Optional.of(IOUtils.toByteArray(is));
|
return Optional.of(IOUtils.toByteArray(is));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new HoodieIOException("Could not read commit details from " + detailPath, e);
|
throw new HoodieIOException("Could not read commit details from " + detailPath, e);
|
||||||
} finally {
|
|
||||||
if (is != null) {
|
|
||||||
Closeables.closeQuietly(is);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.uber.hoodie.common.table.timeline;
|
package com.uber.hoodie.common.table.timeline;
|
||||||
|
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
import com.uber.hoodie.common.table.HoodieTimeline;
|
import com.uber.hoodie.common.table.HoodieTimeline;
|
||||||
import com.uber.hoodie.common.util.FSUtils;
|
import com.uber.hoodie.common.util.FSUtils;
|
||||||
import com.uber.hoodie.exception.HoodieIOException;
|
import com.uber.hoodie.exception.HoodieIOException;
|
||||||
@@ -56,10 +55,8 @@ public class HoodieArchivedTimeline extends HoodieDefaultTimeline {
|
|||||||
public HoodieArchivedTimeline(FileSystem fs, String metaPath) {
|
public HoodieArchivedTimeline(FileSystem fs, String metaPath) {
|
||||||
// Read back the commits to make sure
|
// Read back the commits to make sure
|
||||||
Path archiveLogPath = getArchiveLogPath(metaPath);
|
Path archiveLogPath = getArchiveLogPath(metaPath);
|
||||||
try {
|
try (SequenceFile.Reader reader =
|
||||||
SequenceFile.Reader reader =
|
new SequenceFile.Reader(fs.getConf(), SequenceFile.Reader.file(archiveLogPath))) {
|
||||||
new SequenceFile.Reader(fs.getConf(), SequenceFile.Reader.file(archiveLogPath));
|
|
||||||
try {
|
|
||||||
Text key = new Text();
|
Text key = new Text();
|
||||||
Text val = new Text();
|
Text val = new Text();
|
||||||
while (reader.next(key, val)) {
|
while (reader.next(key, val)) {
|
||||||
@@ -70,9 +67,6 @@ public class HoodieArchivedTimeline extends HoodieDefaultTimeline {
|
|||||||
this.instants = readCommits.keySet().stream().map(
|
this.instants = readCommits.keySet().stream().map(
|
||||||
s -> new HoodieInstant(false, HoodieTimeline.COMMIT_ACTION, s)).collect(
|
s -> new HoodieInstant(false, HoodieTimeline.COMMIT_ACTION, s)).collect(
|
||||||
Collectors.toList());
|
Collectors.toList());
|
||||||
} finally {
|
|
||||||
Closeables.closeQuietly(reader);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new HoodieIOException(
|
throw new HoodieIOException(
|
||||||
"Could not load archived commit timeline from path " + archiveLogPath, e);
|
"Could not load archived commit timeline from path " + archiveLogPath, e);
|
||||||
|
|||||||
Reference in New Issue
Block a user