1
1
/*
2
2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
3
*
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.
5
5
*
6
6
* The contents of this file are subject to the terms of either the GNU
7
7
* 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
693
693
}
694
694
final ClientRuntime runtime = request ().getClientRuntime ();
695
695
final RequestScope requestScope = runtime .getRequestScope ();
696
+ //noinspection Duplicates
696
697
return requestScope .runInScope (new Producer <T >() {
697
698
@ Override
698
699
public T call () throws ProcessingException {
@@ -715,6 +716,7 @@ public <T> T invoke(final GenericType<T> responseType) throws ProcessingExceptio
715
716
}
716
717
final ClientRuntime runtime = request ().getClientRuntime ();
717
718
final RequestScope requestScope = runtime .getRequestScope ();
719
+ //noinspection Duplicates
718
720
return requestScope .runInScope (new Producer <T >() {
719
721
@ Override
720
722
public T call () throws ProcessingException {
@@ -761,6 +763,7 @@ public <T> Future<T> submit(final Class<T> responseType) {
761
763
throw new IllegalArgumentException (LocalizationMessages .RESPONSE_TYPE_IS_NULL ());
762
764
}
763
765
final SettableFuture <T > responseFuture = SettableFuture .create ();
766
+ //noinspection Duplicates
764
767
request ().getClientRuntime ().submit (requestForCall (requestContext ), new ResponseCallback () {
765
768
766
769
@ Override
@@ -823,6 +826,7 @@ public <T> Future<T> submit(final GenericType<T> responseType) {
823
826
throw new IllegalArgumentException (LocalizationMessages .RESPONSE_TYPE_IS_NULL ());
824
827
}
825
828
final SettableFuture <T > responseFuture = SettableFuture .create ();
829
+ //noinspection Duplicates
826
830
request ().getClientRuntime ().submit (requestForCall (requestContext ), new ResponseCallback () {
827
831
828
832
@ Override
@@ -866,7 +870,9 @@ private <T> T translate(final ClientResponse response, final RequestScope scope,
866
870
try {
867
871
return response .readEntity (responseType );
868
872
} 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 );
870
876
} catch (final WebApplicationException ex ) {
871
877
throw new ResponseProcessingException (new InboundJaxrsResponse (response , scope ), ex );
872
878
} catch (final Exception ex ) {
@@ -910,7 +916,12 @@ public <T> Future<T> submit(final GenericType<T> responseType, final InvocationC
910
916
911
917
if (responseType == null ) {
912
918
// 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
+ }
914
925
callbackParamClass = ReflectionHelper .erasure (callbackParamType );
915
926
} else {
916
927
callbackParamType = responseType .getType ();
@@ -958,6 +969,7 @@ public void failed(final ProcessingException error) {
958
969
request ().getClientRuntime ().submit (requestForCall (requestContext ), responseCallback );
959
970
} catch (final Throwable error ) {
960
971
final ProcessingException ce ;
972
+ //noinspection ChainOfInstanceofChecks
961
973
if (error instanceof ProcessingException ) {
962
974
ce = (ProcessingException ) error ;
963
975
responseFuture .setException (ce );
0 commit comments