Skip to content

Attempt to close kudu scanner only one time #17462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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 @@ -45,6 +45,8 @@ public class KuduRecordCursor

private long totalBytes;

private volatile boolean closed;

public KuduRecordCursor(KuduScanner scanner, KuduTable table, List<Type> columnTypes, Map<Integer, Integer> fieldMapping)
{
this.scanner = requireNonNull(scanner, "scanner is null");
Expand Down Expand Up @@ -84,6 +86,7 @@ private int mapping(int field)
public boolean advanceNextPosition()
{
if (!kuduScannerIterator.hasNext()) {
closed = scanner.isClosed();
return false;
}

Expand Down Expand Up @@ -153,12 +156,17 @@ private PartialRow buildPrimaryKey()
@Override
public void close()
{
try {
scanner.close();
}
catch (KuduException e) {
throw new RuntimeException(e);
if (!closed) {
try {
scanner.close();
}
catch (KuduException e) {
throw new RuntimeException(e);
}
finally {
currentRow = null;
closed = true;
}
}
currentRow = null;
}
}