File tree Expand file tree Collapse file tree 3 files changed +32
-3
lines changed
main/java/io/temporal/internal
test/java/io/temporal/workflow/searchattributes Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,8 @@ StartWorkflowExecutionRequest.Builder newStartWorkflowExecutionRequest(
132
132
"Cannot have search attributes and typed search attributes" );
133
133
}
134
134
request .setSearchAttributes (SearchAttributesUtil .encode (options .getSearchAttributes ()));
135
- } else if (options .getTypedSearchAttributes () != null ) {
135
+ } else if (options .getTypedSearchAttributes () != null
136
+ && options .getTypedSearchAttributes ().size () > 0 ) {
136
137
request .setSearchAttributes (
137
138
SearchAttributesUtil .encodeTyped (options .getTypedSearchAttributes ()));
138
139
}
Original file line number Diff line number Diff line change @@ -865,7 +865,8 @@ private StartChildWorkflowExecutionParameters createChildWorkflowParameters(
865
865
"Cannot have both typed search attributes and search attributes" );
866
866
}
867
867
attributes .setSearchAttributes (SearchAttributesUtil .encode (searchAttributes ));
868
- } else if (options .getTypedSearchAttributes () != null ) {
868
+ } else if (options .getTypedSearchAttributes () != null
869
+ && options .getTypedSearchAttributes ().size () > 0 ) {
869
870
attributes .setSearchAttributes (
870
871
SearchAttributesUtil .encodeTyped (options .getTypedSearchAttributes ()));
871
872
}
@@ -1261,7 +1262,8 @@ public void continueAsNew(ContinueAsNewInput input) {
1261
1262
"Cannot have typed search attributes and search attributes" );
1262
1263
}
1263
1264
attributes .setSearchAttributes (SearchAttributesUtil .encode (searchAttributes ));
1264
- } else if (options .getTypedSearchAttributes () != null ) {
1265
+ } else if (options .getTypedSearchAttributes () != null
1266
+ && options .getTypedSearchAttributes ().size () > 0 ) {
1265
1267
attributes .setSearchAttributes (
1266
1268
SearchAttributesUtil .encodeTyped (options .getTypedSearchAttributes ()));
1267
1269
}
Original file line number Diff line number Diff line change @@ -190,6 +190,32 @@ public void testInvalidSearchAttributeKey() {
190
190
}
191
191
}
192
192
193
+ @ Test
194
+ public void testEmptyTypedSearchAttributeKey () {
195
+ WorkflowOptions options =
196
+ SDKTestOptions .newWorkflowOptionsWithTimeouts (testWorkflowRule .getTaskQueue ()).toBuilder ()
197
+ .setTypedSearchAttributes (io .temporal .common .SearchAttributes .EMPTY )
198
+ .build ();
199
+ TestSignaledWorkflow stubF =
200
+ testWorkflowRule .getWorkflowClient ().newWorkflowStub (TestSignaledWorkflow .class , options );
201
+ WorkflowExecution executionF = WorkflowClient .start (stubF ::execute );
202
+
203
+ GetWorkflowExecutionHistoryResponse historyResp =
204
+ WorkflowClientHelper .getHistoryPage (
205
+ testWorkflowRule .getWorkflowServiceStubs (),
206
+ SDKTestWorkflowRule .NAMESPACE ,
207
+ executionF ,
208
+ ByteString .EMPTY ,
209
+ new NoopScope ());
210
+ HistoryEvent startEvent = historyResp .getHistory ().getEvents (0 );
211
+ SearchAttributes searchAttrFromEvent =
212
+ startEvent .getWorkflowExecutionStartedEventAttributes ().getSearchAttributes ();
213
+
214
+ io .temporal .common .SearchAttributes decoded =
215
+ SearchAttributesUtil .decodeTyped (searchAttrFromEvent );
216
+ assertEquals (io .temporal .common .SearchAttributes .EMPTY , decoded );
217
+ }
218
+
193
219
@ Test
194
220
public void testSearchAttributesPresentInChildWorkflow () {
195
221
NoArgsWorkflow client = testWorkflowRule .newWorkflowStubTimeoutOptions (NoArgsWorkflow .class );
You can’t perform that action at this time.
0 commit comments