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) {
|
private RequestInfo getRequestInfo(Request request) {
|
||||||
final String path = Optional.ofNullable(request.getAttribute(URI_INFO_PROPERTY_NAME))
|
final String path = Optional.ofNullable(request.getAttribute(URI_INFO_PROPERTY_NAME))
|
||||||
.map(attr -> UriInfoUtil.getPathTemplate((ExtendedUriInfo) attr))
|
.map(attr -> UriInfoUtil.getPathTemplate((ExtendedUriInfo) attr))
|
||||||
.orElseGet(() -> {
|
.orElseGet(() ->
|
||||||
if (servletPaths.contains(request.getPathInfo())) {
|
Optional.ofNullable(request.getPathInfo())
|
||||||
return request.getPathInfo();
|
.filter(servletPaths::contains)
|
||||||
}
|
.orElse("unknown")
|
||||||
return "unknown";
|
);
|
||||||
});
|
|
||||||
final String method = Optional.ofNullable(request.getMethod()).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
|
// Response cannot be null, but its status might not always reflect an actual response status, since it gets
|
||||||
// initialized to 200
|
// 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
|
// 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
|
// with the mutation operation
|
||||||
final Object resolvedPrincipal = containerRequest.getProperty(RESOLVED_PRINCIPAL_PROPERTY);
|
final Object resolvedPrincipal = containerRequest.getProperty(RESOLVED_PRINCIPAL_PROPERTY);
|
||||||
if (resolvedPrincipal instanceof ReusableAuth.MutableRef ref) {
|
if (resolvedPrincipal instanceof ReusableAuth.MutableRef<?> ref) {
|
||||||
ref.close();
|
ref.close();
|
||||||
} else if (resolvedPrincipal != null) {
|
} else if (resolvedPrincipal != null) {
|
||||||
logger.warn("unexpected resolved principal type {} : {}", resolvedPrincipal.getClass(), resolvedPrincipal);
|
logger.warn("unexpected resolved principal type {} : {}", resolvedPrincipal.getClass(), resolvedPrincipal);
|
||||||
|
|
Loading…
Reference in New Issue