Repository: netty/netty
File: handler/src/test/java/io/netty/handler/ssl/SniClientJava8TestUtil.java (Java)

Code before:
                                            .chooseEngineClientAlias(strings, principals, sslEngine);
                                }

                                @Override
                                public String chooseEngineServerAlias(String s, Principal[] principals,
                                                                      SSLEngine sslEngine) {

                                    SSLSession session = sslEngine.getHandshakeSession();
                                    assertSSLSession(sslEngine.getUseClientMode(), session, name);
                                    return ((X509ExtendedKeyManager) km)
                                            .chooseEngineServerAlias(s, principals, sslEngine);
                                }
                            });
                        } else {
                            managers.add(km);
                        }
                    }
                    return managers.toArray(new KeyManager[0]);
                }
            }, factory.getProvider(), factory.getAlgorithm());
        }
    }

    static SSLSession mockSSLSessionWithSNIHostNameAndPeerHost(String hostname) {
        ExtendedSSLSession session = Mockito.mock(ExtendedSSLSession.class);
        Mockito.when(session.getRequestedServerNames()).thenReturn(Arrays.asList(new SNIHostName(hostname)));
        Mockito.when(session.getPeerHost()).thenReturn(hostname);
        return session;
    }
}


Review comment (suggestion):
```suggestion
        SNIServerName sniName = new SNIHostName(hostname);
        Mockito.when(session.getRequestedServerNames()).thenReturn(Arrays.asList(sniName));
```

Code after:
                                            .chooseEngineClientAlias(strings, principals, sslEngine);
                                }

                                @Override
                                public String chooseEngineServerAlias(String s, Principal[] principals,
                                                                      SSLEngine sslEngine) {

                                    SSLSession session = sslEngine.getHandshakeSession();
                                    assertSSLSession(sslEngine.getUseClientMode(), session, name);
                                    return ((X509ExtendedKeyManager) km)
                                            .chooseEngineServerAlias(s, principals, sslEngine);
                                }
                            });
                        } else {
                            managers.add(km);
                        }
                    }
                    return managers.toArray(new KeyManager[0]);
                }
            }, factory.getProvider(), factory.getAlgorithm());
        }
    }

    static SSLSession mockSSLSessionWithSNIHostNameAndPeerHost(String hostname) {
        ExtendedSSLSession session = Mockito.mock(ExtendedSSLSession.class);
        SNIServerName sniName = new SNIHostName(hostname);
        Mockito.when(session.getRequestedServerNames()).thenReturn(Arrays.asList(sniName));
        Mockito.when(session.getPeerHost()).thenReturn(hostname);
        return session;
    }
}