Skip to content

Commit 4318f54

Browse files
authored
fix(native): Fix an NPE issue in HttpNativeExecutionTaskResultFetcher (#26550)
## Description <!---Describe your changes in detail--> Fixes a potential NPE issue in HttpNativeExecutionTaskResultFetcher. See #22338 ## Motivation and Context <!---Why is this change required? What problem does it solve?--> <!---If it fixes an open issue, please link to the issue here.--> ## Impact <!---Describe any public API or user-facing feature change or any performance impact--> ## Test Plan <!---Please fill in how you tested your change--> ## Contributor checklist - [ ] Please make sure your submission complies with our [contributing guide](https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md), in particular [code style](https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md#code-style) and [commit standards](https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md#commit-standards). - [ ] PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced. - [ ] Documented new properties (with its default value), SQL syntax, functions, or other functionality. - [ ] If release notes are required, they follow the [release notes guidelines](https://github.com/prestodb/presto/wiki/Release-Notes-Guidelines). - [ ] Adequate tests were added if applicable. - [ ] CI passed. - [ ] If adding new dependencies, verified they have an [OpenSSF Scorecard](https://securityscorecards.dev/#the-checks) score of 5.0 or higher (or obtained explicit TSC approval for lower scores). ## Release Notes Please follow [release notes guidelines](https://github.com/prestodb/presto/wiki/Release-Notes-Guidelines) and fill in the release notes below. ``` == NO RELEASE NOTE == ```
1 parent 9265588 commit 4318f54

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

presto-spark-base/src/main/java/com/facebook/presto/spark/execution/nativeprocess/HttpNativeExecutionTaskResultFetcher.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ public class HttpNativeExecutionTaskResultFetcher
6767

6868
private ScheduledFuture<?> scheduledFuture;
6969

70+
private volatile boolean completed;
71+
7072
private long token;
7173

7274
public HttpNativeExecutionTaskResultFetcher(
@@ -134,6 +136,11 @@ private void throwIfFailed()
134136

135137
private void doGetResults()
136138
{
139+
if (completed && scheduledFuture != null) {
140+
scheduledFuture.cancel(false);
141+
return;
142+
}
143+
137144
if (bufferMemoryBytes.longValue() >= MAX_BUFFER_SIZE.toBytes()) {
138145
return;
139146
}
@@ -172,8 +179,11 @@ private void onSuccess(PageBufferClient.PagesResponse pagesResponse)
172179
}
173180
token = nextToken;
174181
if (pagesResponse.isClientComplete()) {
182+
completed = true;
175183
workerClient.abortResultsAsync();
176-
scheduledFuture.cancel(false);
184+
if (scheduledFuture != null) {
185+
scheduledFuture.cancel(false);
186+
}
177187
}
178188
if (!pages.isEmpty()) {
179189
synchronized (taskHasResult) {

0 commit comments

Comments
 (0)