Skip to content

Commit

Permalink
[hotfix][state] Make state iterator adaptor tolerate null iterable input
Browse files Browse the repository at this point in the history
  • Loading branch information
Zakelly committed Dec 9, 2024
1 parent fa9d909 commit 0bad951
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.apache.flink.api.common.state.v2.StateIterator;
import org.apache.flink.core.state.StateFutureUtils;

import javax.annotation.Nullable;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand All @@ -35,9 +37,14 @@ public class CompleteStateIterator<T> implements StateIterator<T> {
final Iterator<T> iterator;
final boolean empty;

public CompleteStateIterator(Iterable<T> iterable) {
this.iterator = iterable.iterator();
this.empty = !iterator.hasNext();
public CompleteStateIterator(@Nullable Iterable<T> iterable) {
if (iterable == null) {
this.iterator = Collections.emptyIterator();
this.empty = true;
} else {
this.iterator = iterable.iterator();
this.empty = !iterator.hasNext();
}
}

@Override
Expand Down

0 comments on commit 0bad951

Please sign in to comment.