public static void close(@Nullable Context context, boolean swallowIOException) throws NamingException {
    if (context == null) {
      return;
    }
    try {
      context.close();
    } catch (NamingException e) {
      if (swallowIOException) {
        LOG.warn("NamingException thrown while closing context.", e);
      } else {
        throw e;
      }
    }
  }
@Test
  public void shouldNotSwallow() throws Exception {
    Context context = mock(Context.class);
    doThrow(new NamingException()).when(context).close();
    assertThatThrownBy(() -> ContextHelper.close(context, false))
      .isInstanceOf(NamingException.class);
  }