Skip to content

Commit

Permalink
tck
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Burke committed May 22, 2019
1 parent ec25445 commit 075bcc0
Show file tree
Hide file tree
Showing 8 changed files with 471 additions and 32 deletions.
Expand Up @@ -28,7 +28,6 @@ public Throwable toThrowable(Response response) {
try {
response.bufferEntity();
} catch (Exception ignored) {}
response.close();
return new WebApplicationException("Unknown error, status code " + response.getStatus(), response);
}

Expand Down
@@ -1,12 +1,12 @@
/**
* Copyright 2015-2017 Red Hat, Inc, and individual contributors.
*
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -41,24 +41,23 @@ public static class HandlerException extends ResponseProcessingException {

public HandlerException(final ClientResponseContext context, final List<ResponseExceptionMapper> candidates) {
super(null, "Handled Internally");
this.handled = ((ClientResponseContextImpl)context).getClientResponse();
this.handled = ((ClientResponseContextImpl) context).getClientResponse();
this.candidates = candidates;
}

public void mapException(final Method method) throws Exception {
try {
for (ResponseExceptionMapper mapper : candidates) {
Throwable exception = mapper.toThrowable(handled);
if (exception instanceof RuntimeException) throw (RuntimeException)exception;
if (exception instanceof Error) throw (Error)exception;
for (Class exc : method.getExceptionTypes()) {
if (exc.isAssignableFrom(exception.getClass())) throw (Exception)exception;
}
public void mapException(final Method method) throws Exception {
// we cannot close the Response as a pointer to the Response could be used in the application
// So, instead, let's buffer it which will close the underlying stream.
handled.bufferEntity();
for (ResponseExceptionMapper mapper : candidates) {
Throwable exception = mapper.toThrowable(handled);
if (exception instanceof RuntimeException) throw (RuntimeException) exception;
if (exception instanceof Error) throw (Error) exception;
for (Class exc : method.getExceptionTypes()) {
if (exc.isAssignableFrom(exception.getClass())) throw (Exception) exception;
}
} finally {
handled.close();
}
}
}
}

public ExceptionMapping(final Set<Object> instances) {
Expand Down
Expand Up @@ -25,6 +25,7 @@
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.microprofile.client.async.AsyncInvocationInterceptorHandler;
import org.jboss.resteasy.microprofile.client.async.AsyncInterceptorRxInvokerProvider;
import org.jboss.resteasy.microprofile.client.header.ClientHeaderProviders;
import org.jboss.resteasy.microprofile.client.header.ClientHeadersRequestFilter;
import org.jboss.resteasy.specimpl.ResteasyUriBuilder;
Expand Down Expand Up @@ -195,6 +196,7 @@ public <T> T build(Class<T> aClass) throws IllegalStateException, RestClientDefi

client = resteasyClientBuilder
.build();
client.register(AsyncInterceptorRxInvokerProvider.class);

actualClient = client.target(baseURI)
.proxyBuilder(aClass)
Expand Down

0 comments on commit 075bcc0

Please sign in to comment.