@Test
    void testRejectedUpgrade() throws Exception {
        final InetSocketAddress remoteAddress = new InetSocketAddress("127.0.0.1", http1Port());

        assertThat(SessionProtocolNegotiationCache.isUnsupported(remoteAddress, H2C)).isFalse();

        final HelloService.Iface client =
                ThriftClients.newClient(http1uri(H2C), HelloService.Iface.class);

        assertThatThrownBy(() -> client.hello("unused"))
                .isInstanceOfSatisfying(UnprocessedRequestException.class, e -> {
                    assertThat(e).hasCauseInstanceOf(SessionProtocolNegotiationException.class);
                    final SessionProtocolNegotiationException cause =
                            (SessionProtocolNegotiationException) e.getCause();

                    // Test if a failed upgrade attempt triggers an exception with
                    // both 'expected' and 'actual' protocols.
                    assertThat(cause.expected()).isEqualTo(H2C);
                    assertThat(cause.actual()).isEqualTo(H1C);
                    // .. and if the negotiation cache is updated.
                    assertThat(SessionProtocolNegotiationCache.isUnsupported(remoteAddress, H2C)).isTrue();
                });

        assertThatThrownBy(() -> client.hello("unused"))
                .isInstanceOfSatisfying(UnprocessedRequestException.class, e -> {
                    assertThat(e).hasCauseInstanceOf(SessionProtocolNegotiationException.class);
                    final SessionProtocolNegotiationException cause =
                            (SessionProtocolNegotiationException) e.getCause();
                    // Test if no upgrade attempt is made thanks to the cache.
                    assertThat(cause.expected()).isEqualTo(H2C);
                    // It has no idea about the actual protocol, because it did not create any connection.
                    assertThat(cause.actual()).isNull();
                });
    }
{@link SessionProtocolNegotiationException} should be raised if a user specified H2C explicitly and the
client failed to upgrade.
thrift/thrift0.13/src/test/java/com/linecorp/armeria/client/thrift/ThriftOverHttpClientTServletIntegrationTest.java