Skip to content

Commit

Permalink
Merge branch 'jetty-10.0.x' into jetty-11.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
olamy committed Mar 23, 2020
2 parents 69bbc6c + d3567fc commit e37552b
Show file tree
Hide file tree
Showing 24 changed files with 567 additions and 1,019 deletions.
Expand Up @@ -704,18 +704,9 @@ private void assertSignatureValid(Class<?> endpointClass, Method method, Class<?
}
}

private MethodHandles.Lookup getMethodHandleLookup(Class<?> endpointClass) throws InvalidWebSocketException
private MethodHandles.Lookup getMethodHandleLookup(Class<?> endpointClass)
{
MethodHandles.Lookup lookup;
try
{
lookup = MethodHandles.privateLookupIn(endpointClass, MethodHandles.lookup());
}
catch (IllegalAccessException e)
{
throw new InvalidWebSocketException("Unable to obtain MethodHandle lookup for " + endpointClass, e);
}
return lookup;
return MethodHandles.publicLookup().in(endpointClass);
}

private static class DecodedArgs
Expand Down
Expand Up @@ -89,15 +89,8 @@ public void testBatchModeOn() throws Exception

URI uri = server.getWsUri();

final CountDownLatch latch = new CountDownLatch(1);
EndpointAdapter endpoint = new EndpointAdapter()
{
@Override
public void onMessage(String message)
{
latch.countDown();
}
};
CountDownLatch latch = new CountDownLatch(1);
EndpointAdapter endpoint = new EndpointAdapter(latch);

try (Session session = client.connectToServer(endpoint, config, uri))
{
Expand Down Expand Up @@ -126,15 +119,8 @@ public void testBatchModeOff() throws Exception

URI uri = server.getWsUri();

final CountDownLatch latch = new CountDownLatch(1);
EndpointAdapter endpoint = new EndpointAdapter()
{
@Override
public void onMessage(String message)
{
latch.countDown();
}
};
CountDownLatch latch = new CountDownLatch(1);
EndpointAdapter endpoint = new EndpointAdapter(latch);

try (Session session = client.connectToServer(endpoint, config, uri))
{
Expand All @@ -157,15 +143,8 @@ public void testBatchModeAuto() throws Exception

URI uri = server.getWsUri();

final CountDownLatch latch = new CountDownLatch(1);
EndpointAdapter endpoint = new EndpointAdapter()
{
@Override
public void onMessage(String message)
{
latch.countDown();
}
};
CountDownLatch latch = new CountDownLatch(1);
EndpointAdapter endpoint = new EndpointAdapter(latch);

try (Session session = client.connectToServer(endpoint, config, uri))
{
Expand All @@ -180,12 +159,25 @@ public void onMessage(String message)
}
}

public abstract static class EndpointAdapter extends Endpoint implements MessageHandler.Whole<String>
public static class EndpointAdapter extends Endpoint implements MessageHandler.Whole<String>
{
private final CountDownLatch latch;

public EndpointAdapter(CountDownLatch latch)
{
this.latch = latch;
}

@Override
public void onOpen(Session session, EndpointConfig config)
{
session.addMessageHandler(this);
}

@Override
public void onMessage(String message)
{
latch.countDown();
}
}
}
Expand Up @@ -456,18 +456,9 @@ private void assertSignatureValid(Class<?> endpointClass, Method method, Class<?
throw new InvalidSignatureException(err.toString());
}

private MethodHandles.Lookup getMethodHandleLookup(Class<?> endpointClass) throws InvalidWebSocketException
private MethodHandles.Lookup getMethodHandleLookup(Class<?> endpointClass)
{
MethodHandles.Lookup lookup;
try
{
lookup = MethodHandles.privateLookupIn(endpointClass, MethodHandles.lookup());
}
catch (IllegalAccessException e)
{
throw new InvalidWebSocketException("Unable to obtain MethodHandle lookup for " + endpointClass, e);
}
return lookup;
return MethodHandles.publicLookup().in(endpointClass);
}

@Override
Expand Down

0 comments on commit e37552b

Please sign in to comment.