jiexray commented on code in PR #21410:
URL: https://github.com/apache/flink/pull/21410#discussion_r1044638321
##########
flink-runtime/src/test/java/org/apache/flink/runtime/state/StateBackendTestBase.java:
##########
@@ -1080,23 +1088,41 @@ public void
testKryoRegisteringRestoreResilienceWithRegisteredSerializer() throw
// on the second restore, since the custom serializer will be used
for
// deserialization, we expect the deliberate failure to be thrown
- expectedException.expect(
- anyOf(
- isA(ExpectedKryoTestException.class),
- Matchers.<Throwable>hasProperty(
- "cause",
isA(ExpectedKryoTestException.class))));
-
- // state backends that eagerly deserializes (such as the memory
state backend) will fail
- // here
- backend = restoreKeyedBackend(IntSerializer.INSTANCE, snapshot2,
env);
-
- state =
- backend.getPartitionedState(
- VoidNamespace.INSTANCE,
VoidNamespaceSerializer.INSTANCE, kvId);
-
- backend.setCurrentKey(1);
- // state backends that lazily deserializes (such as RocksDB) will
fail here
- state.value();
+ assertThatThrownBy(
+ () -> {
+ // state backends that eagerly deserializes
(such as the memory
+ // state backend) will fail
+ // here
+ CheckpointableKeyedStateBackend<Integer>
restoreBackend = null;
+ try {
+ restoreBackend =
+ restoreKeyedBackend(
+ IntSerializer.INSTANCE,
snapshot2, env);
+
+ ValueState<TestPojo> restoreState =
+ restoreBackend.getPartitionedState(
+ VoidNamespace.INSTANCE,
+
VoidNamespaceSerializer.INSTANCE,
+ new
ValueStateDescriptor<>("id", pojoType));
+
+ restoreBackend.setCurrentKey(1);
+ // state backends that lazily deserializes
(such as RocksDB)
+ // will fail here
+ restoreState.value();
+ } finally {
+ if (restoreBackend != null) {
+ restoreBackend.dispose();
+ }
+ }
+ })
+ .satisfiesAnyOf(
+ actual ->
+ assertThat(actual)
+
.isInstanceOf(ExpectedKryoTestException.class),
+ actual ->
+ assertThat(actual)
+ .hasFieldOrProperty("cause")
Review Comment:
The same condition as mentioned in the former question.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]