Skip to content

Commit

Permalink
merge: #10491
Browse files Browse the repository at this point in the history
10491: Do not use null as KeyGenerator r=saig0 a=Zelldon

## Description

Based on review hint here #10440 (comment) 
<!-- Please explain the changes you made here. -->

## Related issues

<!-- Which issues are closed by this PR or are related -->

closes #



Co-authored-by: Christopher Zell <zelldon91@googlemail.com>
  • Loading branch information
zeebe-bors-camunda[bot] and Zelldon committed Sep 27, 2022
2 parents 1f599fc + 9042ece commit 6c9f7e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import io.camunda.zeebe.engine.state.mutable.MutableZeebeState;
import io.camunda.zeebe.engine.state.processing.DbBlackListState;
import io.camunda.zeebe.engine.state.variable.DbVariableState;
import java.util.Objects;
import java.util.function.BiConsumer;

public class ZeebeDbState implements MutableZeebeState {
Expand Down Expand Up @@ -78,7 +79,7 @@ public ZeebeDbState(
final KeyGenerator keyGenerator) {
this.partitionId = partitionId;
this.zeebeDb = zeebeDb;
this.keyGenerator = keyGenerator;
this.keyGenerator = Objects.requireNonNull(keyGenerator);

variableState = new DbVariableState(zeebeDb, transactionContext);
processState = new DbProcessState(zeebeDb, transactionContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,15 @@ private void ensureServiceIsOpened() {
}
if (state == null) {
// service is used for the first time, create state now
// we don't need a key generator here, so we set it to null
// we don't need a key generator here, so we set it to unsupported
state =
new ZeebeDbState(Protocol.DEPLOYMENT_PARTITION, zeebeDb, zeebeDb.createContext(), null);
new ZeebeDbState(
Protocol.DEPLOYMENT_PARTITION,
zeebeDb,
zeebeDb.createContext(),
() -> {
throw new UnsupportedOperationException("Not allowed to generate a new key");
});
}
}
}

0 comments on commit 6c9f7e4

Please sign in to comment.