public void dispatch(JCacheEntryEvent<K, V> event) {
    try {
      if (event.getSource().isClosed()) {
        return;
      }
      switch (event.getEventType()) {
        case CREATED:
          onCreated(event);
          return;
        case UPDATED:
          onUpdated(event);
          return;
        case REMOVED:
          onRemoved(event);
          return;
        case EXPIRED:
          onExpired(event);
          return;
      }
      logger.log(Level.WARNING, "Unknown event type: {}",
          event.getEventType(), new IllegalStateException());
    } catch (RuntimeException e) {
      logger.log(Level.WARNING, "", e);
    } catch (Throwable t) {
      logger.log(Level.ERROR, "", t);
    }
  }
@Test
  public void closed() throws IOException {
    when(cache.isClosed()).thenReturn(true);
    CacheEntryListener<Integer, Integer> listener = Mockito.mock();
    try (var forwarder = new EventTypeAwareListener<>(listener)) {
      forwarder.dispatch(new JCacheEntryEvent<>(cache, EventType.CREATED,
          /* key */ 1, /* hasOldValue */ false, /* oldValue */ null, /* newValue */ 2));
      verifyNoInteractions(listener);
    }
  }