Skip to content

Commit f139c7a

Browse files
authored
Fix bug in calling netty buffer release for Async GetWorkflowExecutionHistory (#493)
1 parent 6bbb997 commit f139c7a

File tree

3 files changed

+31
-26
lines changed

3 files changed

+31
-26
lines changed

src/main/java/com/uber/cadence/client/WorkflowOptions.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,10 @@ public Builder setWorkflowId(String workflowId) {
124124
* conditions Cadence allows two workflows with the same domain and workflow id run
125125
* simultaneously.
126126
* <li>
127-
* <ul>
128-
* AllowDuplicateFailedOnly is a default value. It means that workflow can start if
129-
* previous run failed or was cancelled or terminated.
127+
*
128+
* <ul>
129+
* AllowDuplicateFailedOnly is a default value. It means that workflow can start if
130+
* previous run failed or was cancelled or terminated.
130131
* </ul>
131132
*
132133
* <ul>
@@ -139,9 +140,8 @@ public Builder setWorkflowId(String workflowId) {
139140
*
140141
* <ul>
141142
* TerminateIfRunning terminate current running workflow using the same workflow ID if exist,
142-
* then start a new run in one transaction
143+
* then start a new run in one transaction
143144
* </ul>
144-
* </li>
145145
*/
146146
public Builder setWorkflowIdReusePolicy(WorkflowIdReusePolicy workflowIdReusePolicy) {
147147
this.workflowIdReusePolicy = workflowIdReusePolicy;

src/main/java/com/uber/cadence/serviceclient/WorkflowServiceTChannel.java

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,14 +2302,14 @@ public void StartWorkflowExecution(
23022302
public void GetWorkflowExecutionHistory(
23032303
GetWorkflowExecutionHistoryRequest getRequest, AsyncMethodCallback resultHandler) {
23042304
CompletableFuture<ThriftResponse<GetWorkflowExecutionHistory_result>> response = null;
2305-
try {
2306-
ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args> request =
2307-
buildGetWorkflowExecutionHistoryThriftRequest(getRequest);
2308-
response = doRemoteCallAsync(request);
2309-
2310-
response
2311-
.whenComplete(
2312-
(r, e) -> {
2305+
ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args> request =
2306+
buildGetWorkflowExecutionHistoryThriftRequest(getRequest);
2307+
response = doRemoteCallAsync(request);
2308+
2309+
response
2310+
.whenComplete(
2311+
(r, e) -> {
2312+
try {
23132313
if (e != null) {
23142314
resultHandler.onError(CheckedExceptionWrapper.wrap(e));
23152315
return;
@@ -2336,18 +2336,17 @@ public void GetWorkflowExecutionHistory(
23362336
resultHandler.onError(
23372337
new TException(
23382338
"GetWorkflowExecutionHistory failed with unknown " + "error:" + result));
2339-
return;
2340-
})
2341-
.exceptionally(
2342-
(e) -> {
2343-
log.error("Unexpected error in GetWorkflowExecutionHistory", e);
2344-
return null;
2345-
});
2346-
} finally {
2347-
if (response != null && response.isDone()) {
2348-
response.join().release();
2349-
}
2350-
}
2339+
} finally {
2340+
if (r != null) {
2341+
r.release();
2342+
}
2343+
}
2344+
})
2345+
.exceptionally(
2346+
(e) -> {
2347+
log.error("Unexpected error in GetWorkflowExecutionHistory", e);
2348+
return null;
2349+
});
23512350
}
23522351

23532352
@Override

src/test/java/com/uber/cadence/workflow/WorkflowTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@
1818
package com.uber.cadence.workflow;
1919

2020
import static com.uber.cadence.worker.NonDeterministicWorkflowPolicy.FailWorkflow;
21-
import static org.junit.Assert.*;
21+
import static org.junit.Assert.assertEquals;
22+
import static org.junit.Assert.assertFalse;
23+
import static org.junit.Assert.assertNotEquals;
24+
import static org.junit.Assert.assertNotNull;
25+
import static org.junit.Assert.assertNull;
26+
import static org.junit.Assert.assertTrue;
27+
import static org.junit.Assert.fail;
2228

2329
import com.google.common.util.concurrent.UncheckedExecutionException;
2430
import com.uber.cadence.GetWorkflowExecutionHistoryResponse;

0 commit comments

Comments
 (0)