Skip to content

Commit

Permalink
Replace null Configuration in ContainerRequest with an empty instance
Browse files Browse the repository at this point in the history
to prevent possible NPE

Signed-off-by: jansupol <[email protected]>
  • Loading branch information
jansupol committed Apr 12, 2021
1 parent d2b7b65 commit 66aeadd
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -31,6 +31,7 @@
import java.util.function.Function;
import java.util.stream.Collectors;

import javax.ws.rs.RuntimeType;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.ContainerResponseFilter;
Expand Down Expand Up @@ -63,6 +64,8 @@
import org.glassfish.jersey.message.internal.OutboundJaxrsResponse;
import org.glassfish.jersey.message.internal.TracingAwarePropertiesDelegate;
import org.glassfish.jersey.message.internal.VariantSelector;
import org.glassfish.jersey.model.internal.CommonConfig;
import org.glassfish.jersey.model.internal.ComponentBag;
import org.glassfish.jersey.model.internal.RankedProvider;
import org.glassfish.jersey.process.Inflector;
import org.glassfish.jersey.server.internal.LocalizationMessages;
Expand Down Expand Up @@ -119,7 +122,7 @@ public class ContainerRequest extends InboundMessageContext
// True if the request is used in the response processing phase (for example in ContainerResponseFilter)
private boolean inResponseProcessingPhase;
// lazy PropertiesResolver
private LazyValue<PropertiesResolver> propertiesResolver = Values.lazy(
private final LazyValue<PropertiesResolver> propertiesResolver = Values.lazy(
(Value<PropertiesResolver>) () -> PropertiesResolver.create(getConfiguration(), getPropertiesDelegate())
);

Expand Down Expand Up @@ -188,7 +191,12 @@ public ContainerRequest(
final String httpMethod,
final SecurityContext securityContext,
final PropertiesDelegate propertiesDelegate) {
this(baseUri, requestUri, httpMethod, securityContext, propertiesDelegate, (Configuration) null);
this(baseUri, requestUri, httpMethod, securityContext, propertiesDelegate,
new CommonConfig(RuntimeType.SERVER, ComponentBag.EXCLUDE_EMPTY) {
{
this.property(ContainerRequest.class.getName(), Deprecated.class.getSimpleName());
}
});
}

/**
Expand Down

0 comments on commit 66aeadd

Please sign in to comment.