@Override public <S extends MergingState<?, ?>> void mergePartitionedState(StateDescriptor<S, ?> stateDescriptor) { try { S rawState = stateBackend.getOrCreateKeyedState(windowSerializer, stateDescriptor); if (rawState instanceof InternalMergingState) { @SuppressWarnings("unchecked") InternalMergingState<K, W, ?, ?, ?> mergingState = (InternalMergingState<K, W, ?, ?, ?>) rawState; mergingState.mergeNamespaces(window, mergedWindows); } else { throw new IllegalArgumentException( "The given state descriptor does not refer to a mergeable state (MergingState)"); } } catch (Exception e) { throw new RuntimeException("Error while merging state.", e); } } }