Skip to content

Commit

Permalink
Merge pull request #3037 from jamezp/RESTEASY-3078
Browse files Browse the repository at this point in the history
[RESTEASY-3078] replace some getProperty calls to hasProperty
  • Loading branch information
jamezp committed Mar 2, 2022
2 parents 68e4d50 + d18c8d5 commit dd671f9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
Expand Up @@ -152,10 +152,9 @@ private CompletableFuture<ClientResponse> submit(final ClientInvocation request)

options.setURI(uri.getRawPath());


Object timeout = request.getConfiguration().getProperty(REQUEST_TIMEOUT_MS);
if (timeout != null) {
long timeoutMs = unwrapTimeout(timeout);
if (request.getConfiguration().hasProperty(REQUEST_TIMEOUT_MS)) {
long timeoutMs = unwrapTimeout(
request.getConfiguration().getProperty(REQUEST_TIMEOUT_MS));
if (timeoutMs > 0) {
options.setTimeout(timeoutMs);
}
Expand Down
Expand Up @@ -86,7 +86,7 @@ private Response cachedResponse(BrowserCache.Entry entry)
@Override
public void filter(ClientRequestContext request, ClientResponseContext response) throws IOException
{
if (!request.getMethod().equalsIgnoreCase("GET") || request.getProperty("cached") != null) return;
if (!request.getMethod().equalsIgnoreCase("GET") || request.hasProperty("cached")) return;
else if (response.getStatus() == 304)
{
BrowserCache.Entry entry = (BrowserCache.Entry)request.getProperty("expired.cache.entry");
Expand Down
Expand Up @@ -432,16 +432,19 @@ public ResteasyClient build()
*/
private void setProxyIfNeeded(ClientConfiguration clientConfig) {
try {
Object proxyHostProp = clientConfig.getProperty(ResteasyClientBuilder.PROPERTY_PROXY_HOST);
if (proxyHostProp != null) {
Object proxyPortProp = clientConfig.getProperty(ResteasyClientBuilder.PROPERTY_PROXY_PORT);
// default if the port is not set or if it is not string or number
if (clientConfig.hasProperty(ResteasyClientBuilder.PROPERTY_PROXY_HOST)) {
Object proxyHostProp = clientConfig.getProperty(ResteasyClientBuilder.PROPERTY_PROXY_HOST);
Integer proxyPort = -1;
if (proxyPortProp != null && proxyPortProp instanceof Number) {
proxyPort = ((Number) proxyPortProp).intValue();
} else if (proxyPortProp != null && proxyPortProp instanceof String) {
proxyPort = Integer.parseInt((String) proxyPortProp);
if (clientConfig.hasProperty(ResteasyClientBuilder.PROPERTY_PROXY_PORT)) {
// default if the port is not set or if it is not string or number
Object proxyPortProp = clientConfig.getProperty(ResteasyClientBuilder.PROPERTY_PROXY_PORT);
if (proxyPortProp instanceof Number) {
proxyPort = ((Number) proxyPortProp).intValue();
} else if (proxyPortProp instanceof String) {
proxyPort = Integer.parseInt((String) proxyPortProp);
}
}

Object proxySchemeProp = clientConfig.getProperty(ResteasyClientBuilder.PROPERTY_PROXY_SCHEME);
defaultProxy((String)proxyHostProp, proxyPort, (String)proxySchemeProp);
}
Expand Down
Expand Up @@ -30,8 +30,7 @@ public class DigitalVerificationInterceptor implements ReaderInterceptor
public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException
{
LogMessages.LOGGER.debugf("Interceptor : %s, Method : aroundReadFrom", getClass().getName());
Verifier verifier = (Verifier) context.getProperty(Verifier.class.getName());
if (verifier == null)
if (!context.hasProperty(Verifier.class.getName()))
{
return context.proceed();
}
Expand Down Expand Up @@ -64,6 +63,7 @@ public Object aroundReadFrom(ReaderInterceptorContext context) throws IOExceptio
context.setInputStream(stream);
Object rtn = context.proceed();
byte[] body = stream.toByteArray();
Verifier verifier = (Verifier) context.getProperty(Verifier.class.getName());

if (verifier.getRepository() == null)
{
Expand Down

0 comments on commit dd671f9

Please sign in to comment.