11/*
22 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33 *
4- * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved.
4+ * Copyright (c) 2011-2016 Oracle and/or its affiliates. All rights reserved.
55 *
66 * The contents of this file are subject to the terms of either the GNU
77 * General Public License Version 2 only ("GPL") or the Common Development
@@ -693,6 +693,7 @@ public <T> T invoke(final Class<T> responseType) throws ProcessingException, Web
693693 }
694694 final ClientRuntime runtime = request ().getClientRuntime ();
695695 final RequestScope requestScope = runtime .getRequestScope ();
696+ //noinspection Duplicates
696697 return requestScope .runInScope (new Producer <T >() {
697698 @ Override
698699 public T call () throws ProcessingException {
@@ -715,6 +716,7 @@ public <T> T invoke(final GenericType<T> responseType) throws ProcessingExceptio
715716 }
716717 final ClientRuntime runtime = request ().getClientRuntime ();
717718 final RequestScope requestScope = runtime .getRequestScope ();
719+ //noinspection Duplicates
718720 return requestScope .runInScope (new Producer <T >() {
719721 @ Override
720722 public T call () throws ProcessingException {
@@ -761,6 +763,7 @@ public <T> Future<T> submit(final Class<T> responseType) {
761763 throw new IllegalArgumentException (LocalizationMessages .RESPONSE_TYPE_IS_NULL ());
762764 }
763765 final SettableFuture <T > responseFuture = SettableFuture .create ();
766+ //noinspection Duplicates
764767 request ().getClientRuntime ().submit (requestForCall (requestContext ), new ResponseCallback () {
765768
766769 @ Override
@@ -823,6 +826,7 @@ public <T> Future<T> submit(final GenericType<T> responseType) {
823826 throw new IllegalArgumentException (LocalizationMessages .RESPONSE_TYPE_IS_NULL ());
824827 }
825828 final SettableFuture <T > responseFuture = SettableFuture .create ();
829+ //noinspection Duplicates
826830 request ().getClientRuntime ().submit (requestForCall (requestContext ), new ResponseCallback () {
827831
828832 @ Override
@@ -866,7 +870,9 @@ private <T> T translate(final ClientResponse response, final RequestScope scope,
866870 try {
867871 return response .readEntity (responseType );
868872 } catch (final ProcessingException ex ) {
869- throw new ResponseProcessingException (new InboundJaxrsResponse (response , scope ), ex .getCause ());
873+ throw new ResponseProcessingException (
874+ new InboundJaxrsResponse (response , scope ),
875+ ex .getCause () != null ? ex .getCause () : ex );
870876 } catch (final WebApplicationException ex ) {
871877 throw new ResponseProcessingException (new InboundJaxrsResponse (response , scope ), ex );
872878 } catch (final Exception ex ) {
@@ -910,7 +916,12 @@ public <T> Future<T> submit(final GenericType<T> responseType, final InvocationC
910916
911917 if (responseType == null ) {
912918 // If we don't have response use callback to obtain param types.
913- callbackParamType = ReflectionHelper .getParameterizedTypeArguments (pair )[0 ];
919+ final Type [] typeArguments = ReflectionHelper .getParameterizedTypeArguments (pair );
920+ if (typeArguments == null || typeArguments .length == 0 ) {
921+ callbackParamType = Object .class ;
922+ } else {
923+ callbackParamType = typeArguments [0 ];
924+ }
914925 callbackParamClass = ReflectionHelper .erasure (callbackParamType );
915926 } else {
916927 callbackParamType = responseType .getType ();
@@ -958,6 +969,7 @@ public void failed(final ProcessingException error) {
958969 request ().getClientRuntime ().submit (requestForCall (requestContext ), responseCallback );
959970 } catch (final Throwable error ) {
960971 final ProcessingException ce ;
972+ //noinspection ChainOfInstanceofChecks
961973 if (error instanceof ProcessingException ) {
962974 ce = (ProcessingException ) error ;
963975 responseFuture .setException (ce );
0 commit comments