File tree 2 files changed +20
-2
lines changed
main/java/com/uber/cadence/workflow
test/java/com/uber/cadence/workflow
2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -36,8 +36,10 @@ public static <T> T getValueFromSearchAttributes(
36
36
37
37
private static byte [] getValueBytes (SearchAttributes searchAttributes , String key ) {
38
38
ByteBuffer byteBuffer = searchAttributes .getIndexedFields ().get (key );
39
- final byte [] valueBytes = new byte [byteBuffer .limit () - byteBuffer .position ()];
40
- byteBuffer .get (valueBytes , 0 , valueBytes .length );
39
+ final byte [] valueBytes = new byte [byteBuffer .remaining ()];
40
+ byteBuffer .mark ();
41
+ byteBuffer .get (valueBytes );
42
+ byteBuffer .reset ();
41
43
return valueBytes ;
42
44
}
43
45
}
Original file line number Diff line number Diff line change @@ -61,4 +61,20 @@ public void TestGetValueFromSearchAttributes() {
61
61
WorkflowUtils .getValueFromSearchAttributes (
62
62
searchAttributes , "CustomBooleanField" , Boolean .class ));
63
63
}
64
+
65
+ @ Test
66
+ public void TestGetValueFromSearchAttributesRepeated () {
67
+ Map <String , Object > attr = new HashMap <>();
68
+ String stringVal = "keyword" ;
69
+ attr .put ("CustomKeywordField" , stringVal );
70
+ SearchAttributes searchAttributes = InternalUtils .convertMapToSearchAttributes (attr );
71
+ assertEquals (
72
+ stringVal ,
73
+ WorkflowUtils .getValueFromSearchAttributes (
74
+ searchAttributes , "CustomKeywordField" , String .class ));
75
+ assertEquals (
76
+ stringVal ,
77
+ WorkflowUtils .getValueFromSearchAttributes (
78
+ searchAttributes , "CustomKeywordField" , String .class ));
79
+ }
64
80
}
You can’t perform that action at this time.
0 commit comments