@Test
  public void testBadPreambleHeader() throws Exception {
    Configuration clientConf = new Configuration(CONF);
    RpcServer rpcServer = createRpcServer("testRpcServer", Collections.emptyList(),
      new InetSocketAddress("localhost", 0), CONF, new FifoRpcScheduler(CONF, 1));
    try (AbstractRpcClient<?> client = createBadAuthRpcClient(clientConf)) {
      rpcServer.start();
      BlockingInterface stub = newBlockingStub(client, rpcServer.getListenerAddress());
      BadAuthException error = null;
      // for SimpleRpcServer, it is possible that we get a broken pipe before getting the
      // BadAuthException, so we add some retries here, see HBASE-28417
      for (int i = 0; i < 10; i++) {
        IOException ioe = doBadPreableHeaderCall(stub);
        if (ioe instanceof BadAuthException) {
          error = (BadAuthException) ioe;
          break;
        }
        Thread.sleep(100);
      }
      assertNotNull("Can not get expected BadAuthException", error);
      assertThat(error.getMessage(), containsString("authName=unknown"));
    } finally {
      rpcServer.stop();
    }
  }
Tests that the connection closing is handled by the client with outstanding RPC calls
hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/AbstractTestIPC.java