Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
* <p>
* Event key: CF, {datatype}\0{UID}
*/
public abstract class DatawaveFieldIndexCachingIteratorJexl extends WrappingIterator {
public abstract class DatawaveFieldIndexCachingIteratorJexl extends WrappingIterator implements AutoCloseable {

public static final Text ANY_FINAME = new Text("fi\0" + Constants.ANY_FIELD);
public static final Text FI_START = new Text("fi\0");
Expand Down Expand Up @@ -550,9 +550,8 @@ public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> op
}

@Override
protected void finalize() throws Throwable {
public void close() {
clearRowBasedHdfsBackedSet();
super.finalize();
}

@Override
Expand Down Expand Up @@ -1286,7 +1285,7 @@ protected Path getRowDir(Path uniqueDir, String row) {
* Clear out the current row-based hdfs backed set
*
*/
protected void clearRowBasedHdfsBackedSet() {
protected void clearRowBasedHdfsBackedSet() {
this.keys = null;
this.currentRow = null;
this.set = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import datawave.core.common.connection.AccumuloConnectionFactory.Priority;
import datawave.core.common.util.EnvProvider;

public class AccumuloRecordWriter extends RecordWriter<Text,Mutation> {
public class AccumuloRecordWriter extends RecordWriter<Text,Mutation> implements AutoCloseable{
private MultiTableBatchWriter mtbw = null;
private HashMap<Text,BatchWriter> bws = null;
private Text defaultTableName = null;
Expand Down Expand Up @@ -241,9 +241,7 @@ public void close(TaskAttemptContext attempt) throws IOException, InterruptedExc
}
}

@Override
protected void finalize() throws Throwable {
super.finalize();
public void close() {
returnConnector();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* stopped.
*/
@SuppressWarnings("UnstableApiUsage")
public class MergedReadAhead<T> extends AbstractExecutionThreadService implements Iterator<T>, Closeable {
public class MergedReadAhead<T> extends AbstractExecutionThreadService implements Iterator<T>, AutoCloseable {

private static final Logger log = Logger.getLogger(MergedReadAhead.class);

Expand Down Expand Up @@ -129,14 +129,6 @@ public void remove() {
throw new UnsupportedOperationException();
}

public void finalize() throws Throwable {
try {
close();
} finally {
super.finalize();
}
}

@Override
public void close() throws IOException {
log.trace("stopping...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* @param <V>
* value of the map
*/
public abstract class FileSortedMap<K,V> implements SortedMap<K,V>, Cloneable, RewritableSortedMap<K,V> {
public abstract class FileSortedMap<K,V> implements SortedMap<K,V>, Cloneable, RewritableSortedMap<K,V>, AutoCloseable{
private static final Logger log = Logger.getLogger(FileSortedMap.class);
protected boolean persisted;
protected K[] range;
Expand Down Expand Up @@ -776,10 +776,9 @@ public void remove() {
throw new UnsupportedOperationException("Iterator.remove() not supported on a persisted map.");
}

@Override
protected void finalize() throws Throwable {

protected void close() throws Throwable {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be scoped public to be consistent with Autocloseable.

cleanup();
super.finalize();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,12 +762,6 @@ public void remove() {
throw new UnsupportedOperationException("Iterator.remove() not supported.");
}

@Override
protected void finalize() throws Throwable {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FileIterator should probably also implement Autocloseable and call cleanup() in close().

cleanup();
super.finalize();
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,7 @@ private void initialize() {
}
}

@Override
protected void finalize() throws Throwable {
super.finalize();
public void close() throws IOException, InterruptedException {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be annotated with @Override and ShardTableQueryMetricHandler should implement Autocloseable.

this.recordWriter.close(null);
}

Expand Down
Loading