fix simone review comments
Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
This commit is contained in:
parent
9471eff332
commit
a21dab222f
|
@ -62,10 +62,7 @@ public class ConscryptServerALPNProcessor implements ALPNProcessor.Server
|
|||
{
|
||||
try
|
||||
{
|
||||
// with java 9+ we must use
|
||||
//sslEngine.setHandshakeApplicationProtocolSelector(new ALPNCallback((ALPNServerConnection)connection));
|
||||
Conscrypt.setApplicationProtocolSelector(sslEngine,
|
||||
toApplicationProtocolSelector(new ALPNCallback((ALPNServerConnection)connection)));
|
||||
Conscrypt.setApplicationProtocolSelector(sslEngine,new ALPNCallback((ALPNServerConnection)connection));
|
||||
}
|
||||
catch (RuntimeException x)
|
||||
{
|
||||
|
@ -77,14 +74,21 @@ public class ConscryptServerALPNProcessor implements ALPNProcessor.Server
|
|||
}
|
||||
}
|
||||
|
||||
private static ApplicationProtocolSelector toApplicationProtocolSelector(BiFunction<SSLEngine, List<String>, String> selector)
|
||||
private final class ALPNCallback extends ApplicationProtocolSelector implements BiFunction<SSLEngine,List<String>,String>, SslHandshakeListener
|
||||
{
|
||||
return new ApplicationProtocolSelector()
|
||||
private final ALPNServerConnection alpnConnection;
|
||||
|
||||
|
||||
private ALPNCallback(ALPNServerConnection connection)
|
||||
{
|
||||
alpnConnection = connection;
|
||||
((DecryptedEndPoint)alpnConnection.getEndPoint()).getSslConnection().addHandshakeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String selectApplicationProtocol(SSLEngine engine, List<String> protocols)
|
||||
{
|
||||
return selector.apply(engine, protocols);
|
||||
return apply(engine, protocols);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,18 +96,6 @@ public class ConscryptServerALPNProcessor implements ALPNProcessor.Server
|
|||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private final class ALPNCallback implements BiFunction<SSLEngine,List<String>,String>, SslHandshakeListener
|
||||
{
|
||||
private final ALPNServerConnection alpnConnection;
|
||||
|
||||
private ALPNCallback(ALPNServerConnection connection)
|
||||
{
|
||||
alpnConnection = connection;
|
||||
((DecryptedEndPoint)alpnConnection.getEndPoint()).getSslConnection().addHandshakeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(SSLEngine engine, List<String> protocols)
|
||||
|
|
|
@ -63,12 +63,6 @@ public class ConscryptHTTP2ServerTest
|
|||
Security.addProvider(new OpenSSLProvider());
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
throws Exception
|
||||
{
|
||||
new ConscryptHTTP2ServerTest().startServer();
|
||||
}
|
||||
|
||||
private SslContextFactory newSslContextFactory()
|
||||
{
|
||||
Path path = Paths.get("src", "test", "resources");
|
||||
|
@ -90,8 +84,7 @@ public class ConscryptHTTP2ServerTest
|
|||
}
|
||||
|
||||
@BeforeEach
|
||||
public void startServer()
|
||||
throws Exception
|
||||
public void startServer() throws Exception
|
||||
{
|
||||
|
||||
HttpConfiguration httpsConfig = new HttpConfiguration();
|
||||
|
@ -114,9 +107,7 @@ public class ConscryptHTTP2ServerTest
|
|||
server.setHandler(new AbstractHandler()
|
||||
{
|
||||
@Override
|
||||
public void handle(String target,Request baseRequest,HttpServletRequest request,
|
||||
HttpServletResponse response)
|
||||
throws IOException, ServletException
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||
{
|
||||
response.setStatus(200);
|
||||
baseRequest.setHandled(true);
|
||||
|
@ -128,8 +119,7 @@ public class ConscryptHTTP2ServerTest
|
|||
}
|
||||
|
||||
@AfterEach
|
||||
public void stopServer()
|
||||
throws Exception
|
||||
public void stopServer() throws Exception
|
||||
{
|
||||
if (server != null)
|
||||
{
|
||||
|
@ -139,8 +129,7 @@ public class ConscryptHTTP2ServerTest
|
|||
|
||||
|
||||
@Test
|
||||
public void test_simple_query()
|
||||
throws Exception
|
||||
public void test_simple_query() throws Exception
|
||||
{
|
||||
|
||||
HTTP2Client h2Client = new HTTP2Client();
|
||||
|
|
Loading…
Reference in New Issue