use of org.apache.flink.runtime.state.heap.space.Allocator in project flink by apache.
the class CopyOnWriteSkipListStateMapBasicOpTest method testPutWithAllocationFailure.
/**
* Make sure exception will be thrown with allocation failure rather than swallowed.
*/
@Test
public void testPutWithAllocationFailure() {
Allocator exceptionalAllocator = new Allocator() {
@Override
public long allocate(int size) {
throw new RuntimeException("Exception on purpose");
}
@Override
public void free(long address) {
}
@Override
@Nullable
public Chunk getChunkById(int chunkId) {
return null;
}
@Override
public void close() {
}
};
try (CopyOnWriteSkipListStateMap<Integer, Long, String> stateMap = createEmptyStateMap(0, 0.0f, exceptionalAllocator)) {
stateMap.put(1, 1L, "test-value");
fail("Should have thrown exception when space allocation fails");
} catch (FlinkRuntimeException e) {
// expected
}
}
Aggregations