Skip to content

Commit 80f7951

Browse files
author
Liang Mei
committed
address PR comments
1 parent 9ad14eb commit 80f7951

File tree

3 files changed

+47
-44
lines changed

3 files changed

+47
-44
lines changed

src/main/java/com/uber/cadence/internal/external/GenericWorkflowClientExternalImpl.java

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -71,45 +71,7 @@ public IWorkflowService getService() {
7171
public WorkflowExecution startWorkflow(StartWorkflowExecutionParameters startParameters)
7272
throws WorkflowExecutionAlreadyStartedError {
7373
try {
74-
StartWorkflowExecutionRequest request = new StartWorkflowExecutionRequest();
75-
request.setDomain(domain);
76-
77-
request.setInput(startParameters.getInput());
78-
request.setExecutionStartToCloseTimeoutSeconds(
79-
(int) startParameters.getExecutionStartToCloseTimeoutSeconds());
80-
request.setTaskStartToCloseTimeoutSeconds(
81-
(int) startParameters.getTaskStartToCloseTimeoutSeconds());
82-
request.setWorkflowIdReusePolicy(startParameters.getWorkflowIdReusePolicy());
83-
String taskList = startParameters.getTaskList();
84-
if (taskList != null && !taskList.isEmpty()) {
85-
TaskList tl = new TaskList();
86-
tl.setName(taskList);
87-
request.setTaskList(tl);
88-
}
89-
String workflowId = startParameters.getWorkflowId();
90-
if (workflowId == null) {
91-
workflowId = UUID.randomUUID().toString();
92-
}
93-
request.setWorkflowId(workflowId);
94-
request.setWorkflowType(startParameters.getWorkflowType());
95-
96-
// if(startParameters.getChildPolicy() != null) {
97-
// request.setChildPolicy(startParameters.getChildPolicy());
98-
// }
99-
100-
StartWorkflowExecutionResponse result;
101-
try {
102-
result = service.StartWorkflowExecution(request);
103-
} catch (WorkflowExecutionAlreadyStartedError e) {
104-
throw e;
105-
} catch (TException e) {
106-
throw CheckedExceptionWrapper.wrap(e);
107-
}
108-
WorkflowExecution execution = new WorkflowExecution();
109-
execution.setRunId(result.getRunId());
110-
execution.setWorkflowId(request.getWorkflowId());
111-
112-
return execution;
74+
return startWorkflowInternal(startParameters);
11375
} finally {
11476
// TODO: can probably cache this
11577
Map<String, String> tags =
@@ -120,6 +82,49 @@ public WorkflowExecution startWorkflow(StartWorkflowExecutionParameters startPar
12082
}
12183
}
12284

85+
private WorkflowExecution startWorkflowInternal(StartWorkflowExecutionParameters startParameters)
86+
throws WorkflowExecutionAlreadyStartedError {
87+
StartWorkflowExecutionRequest request = new StartWorkflowExecutionRequest();
88+
request.setDomain(domain);
89+
90+
request.setInput(startParameters.getInput());
91+
request.setExecutionStartToCloseTimeoutSeconds(
92+
(int) startParameters.getExecutionStartToCloseTimeoutSeconds());
93+
request.setTaskStartToCloseTimeoutSeconds(
94+
(int) startParameters.getTaskStartToCloseTimeoutSeconds());
95+
request.setWorkflowIdReusePolicy(startParameters.getWorkflowIdReusePolicy());
96+
String taskList = startParameters.getTaskList();
97+
if (taskList != null && !taskList.isEmpty()) {
98+
TaskList tl = new TaskList();
99+
tl.setName(taskList);
100+
request.setTaskList(tl);
101+
}
102+
String workflowId = startParameters.getWorkflowId();
103+
if (workflowId == null) {
104+
workflowId = UUID.randomUUID().toString();
105+
}
106+
request.setWorkflowId(workflowId);
107+
request.setWorkflowType(startParameters.getWorkflowType());
108+
109+
// if(startParameters.getChildPolicy() != null) {
110+
// request.setChildPolicy(startParameters.getChildPolicy());
111+
// }
112+
113+
StartWorkflowExecutionResponse result;
114+
try {
115+
result = service.StartWorkflowExecution(request);
116+
} catch (WorkflowExecutionAlreadyStartedError e) {
117+
throw e;
118+
} catch (TException e) {
119+
throw CheckedExceptionWrapper.wrap(e);
120+
}
121+
WorkflowExecution execution = new WorkflowExecution();
122+
execution.setRunId(result.getRunId());
123+
execution.setWorkflowId(request.getWorkflowId());
124+
125+
return execution;
126+
}
127+
123128
@Override
124129
public void signalWorkflowExecution(SignalExternalWorkflowParameters signalParameters) {
125130
SignalWorkflowExecutionRequest request = new SignalWorkflowExecutionRequest();

src/main/java/com/uber/cadence/internal/metrics/NoopScope.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import com.uber.m3.util.Duration;
2626
import java.util.Map;
2727

28-
public class NoopScope {
28+
public final class NoopScope {
2929
private static class NoopReporter implements StatsReporter {
3030

3131
@Override

src/main/java/com/uber/cadence/internal/worker/ActivityWorker.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,8 @@ private class MeasurableActivityTask {
153153
Stopwatch sw;
154154

155155
MeasurableActivityTask(PollForActivityTaskResponse task, Stopwatch sw) {
156-
Objects.requireNonNull(task);
157-
Objects.requireNonNull(sw);
158-
this.task = task;
159-
this.sw = sw;
156+
this.task = Objects.requireNonNull(task);
157+
this.sw = Objects.requireNonNull(sw);
160158
}
161159

162160
void markDone() {

0 commit comments

Comments
 (0)