WebSocket - better protection on metadata cache
This commit is contained in:
parent
6fc7e23dc0
commit
b63a6047d3
|
@ -31,15 +31,17 @@ public class JettyAnnotatedImpl implements EventDriverImpl
|
|||
public EventDriver create(Object websocket, WebSocketPolicy policy)
|
||||
{
|
||||
Class<?> websocketClass = websocket.getClass();
|
||||
JettyAnnotatedMetadata metadata = cache.get(websocketClass);
|
||||
if (metadata == null)
|
||||
synchronized (cache)
|
||||
{
|
||||
JettyAnnotatedScanner scanner = new JettyAnnotatedScanner();
|
||||
metadata = scanner.scan(websocketClass);
|
||||
cache.put(websocketClass,metadata);
|
||||
JettyAnnotatedMetadata metadata = cache.get(websocketClass);
|
||||
if (metadata == null)
|
||||
{
|
||||
JettyAnnotatedScanner scanner = new JettyAnnotatedScanner();
|
||||
metadata = scanner.scan(websocketClass);
|
||||
cache.put(websocketClass,metadata);
|
||||
}
|
||||
return new JettyAnnotatedEventDriver(policy,websocket,metadata);
|
||||
}
|
||||
|
||||
return new JettyAnnotatedEventDriver(policy,websocket,metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,6 +60,6 @@ public class JettyAnnotatedImpl implements EventDriverImpl
|
|||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("{} [cache.count=%d]",this.getClass().getSimpleName(),cache.size());
|
||||
return String.format("%s [cache.count=%d]",this.getClass().getSimpleName(),cache.size());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue