@Override
    public void returnLogicalSlot(LogicalSlot logicalSlot) {
        LOG.debug("Returning logical slot to shared slot ({})", physicalSlotRequestId);
        Preconditions.checkState(
                state != State.RELEASED, "The shared slot has already been released.");

        Preconditions.checkState(!logicalSlot.isAlive(), "Returned logic slot must not be alive.");
        Preconditions.checkState(
                allocatedLogicalSlots.remove(logicalSlot.getSlotRequestId()) != null,
                "Trying to remove a logical slot request which has been either already removed or never created.");
        tryReleaseExternally();
    }
@Test
    void testReturnLogicalSlotRejectsUnknownSlot() {
        assertThatThrownBy(
                        () -> {
                            final TestingPhysicalSlot physicalSlot =
                                    TestingPhysicalSlot.builder().build();
                            final SharedSlot sharedSlot =
                                    new SharedSlot(
                                            new SlotRequestId(), physicalSlot, false, () -> {});
                            final LogicalSlot logicalSlot =
                                    new TestingLogicalSlotBuilder().createTestingLogicalSlot();
                            logicalSlot.releaseSlot(new Exception("test"));

                            sharedSlot.returnLogicalSlot(logicalSlot);
                        })
                .isInstanceOf(IllegalStateException.class);
    }