Address potential NullPointerException when calling Collection#contains
This commit is contained in:
parent
7d364ca7ce
commit
2dc0ea2b89
|
@ -160,12 +160,11 @@ public class MetricsHttpChannelListener implements HttpChannel.Listener, Contain
|
|||
private RequestInfo getRequestInfo(Request request) {
|
||||
final String path = Optional.ofNullable(request.getAttribute(URI_INFO_PROPERTY_NAME))
|
||||
.map(attr -> UriInfoUtil.getPathTemplate((ExtendedUriInfo) attr))
|
||||
.orElseGet(() -> {
|
||||
if (servletPaths.contains(request.getPathInfo())) {
|
||||
return request.getPathInfo();
|
||||
}
|
||||
return "unknown";
|
||||
});
|
||||
.orElseGet(() ->
|
||||
Optional.ofNullable(request.getPathInfo())
|
||||
.filter(servletPaths::contains)
|
||||
.orElse("unknown")
|
||||
);
|
||||
final String method = Optional.ofNullable(request.getMethod()).orElse("unknown");
|
||||
// Response cannot be null, but its status might not always reflect an actual response status, since it gets
|
||||
// initialized to 200
|
||||
|
|
|
@ -195,7 +195,7 @@ public class WebSocketResourceProvider<T extends Principal> implements WebSocket
|
|||
// If the request ended up being one that mutates our principal, we have to close it to indicate we're done
|
||||
// with the mutation operation
|
||||
final Object resolvedPrincipal = containerRequest.getProperty(RESOLVED_PRINCIPAL_PROPERTY);
|
||||
if (resolvedPrincipal instanceof ReusableAuth.MutableRef ref) {
|
||||
if (resolvedPrincipal instanceof ReusableAuth.MutableRef<?> ref) {
|
||||
ref.close();
|
||||
} else if (resolvedPrincipal != null) {
|
||||
logger.warn("unexpected resolved principal type {} : {}", resolvedPrincipal.getClass(), resolvedPrincipal);
|
||||
|
|
Loading…
Reference in New Issue