Skip to content

Commit

Permalink
[hotfix][state] Fix the wrong type cast in ForStMapState
Browse files Browse the repository at this point in the history
  • Loading branch information
Zakelly committed Jan 13, 2025
1 parent 105720f commit d63a7a4
Showing 1 changed file with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,26 @@ public UK deserializeUserKey(byte[] userKeyBytes, int userKeyOffset) throws IOEx
@Override
@SuppressWarnings("unchecked")
public ForStDBPutRequest<K, N, UV> buildDBPutRequest(StateRequest<?, ?, ?, ?> stateRequest) {
Preconditions.checkArgument(
stateRequest.getRequestType() == StateRequestType.MAP_PUT
|| stateRequest.getRequestType() == StateRequestType.MAP_REMOVE);
ContextKey<K, N> contextKey =
new ContextKey<>(
(RecordContext<K>) stateRequest.getRecordContext(),
(N) stateRequest.getNamespace(),
((Tuple2<UK, UV>) stateRequest.getPayload()).f0);
Preconditions.checkNotNull(stateRequest.getPayload());
ContextKey<K, N> contextKey;
if (stateRequest.getRequestType() == StateRequestType.MAP_PUT) {
contextKey =
new ContextKey<>(
(RecordContext<K>) stateRequest.getRecordContext(),
(N) stateRequest.getNamespace(),
((Tuple2<UK, UV>) stateRequest.getPayload()).f0);
} else if (stateRequest.getRequestType() == StateRequestType.MAP_REMOVE) {
contextKey =
new ContextKey<>(
(RecordContext<K>) stateRequest.getRecordContext(),
(N) stateRequest.getNamespace(),
stateRequest.getPayload());
} else {
throw new IllegalArgumentException(
"The State type is: "
+ stateRequest.getRequestType().name()
+ ", which is not a valid put request.");
}
UV value = null;
if (stateRequest.getRequestType() == StateRequestType.MAP_PUT) {
value = ((Tuple2<UK, UV>) stateRequest.getPayload()).f1;
Expand Down

0 comments on commit d63a7a4

Please sign in to comment.