@@ -140,12 +140,15 @@ public Object invoke(MethodInvocation methodInvocation) throws Throwable {
140140
141141 RemoteInvocation invocation = createRemoteInvocation (methodInvocation );
142142 RemoteInvocationResult result ;
143+
143144 try {
144145 result = executeRequest (invocation , methodInvocation );
145146 }
146147 catch (Throwable ex ) {
147- throw convertHttpInvokerAccessException (ex );
148+ RemoteAccessException rae = convertHttpInvokerAccessException (ex );
149+ throw (rae != null ? rae : ex );
148150 }
151+
149152 try {
150153 return recreateRemoteInvocationResult (result );
151154 }
@@ -161,7 +164,7 @@ public Object invoke(MethodInvocation methodInvocation) throws Throwable {
161164 }
162165
163166 /**
164- * Execute the given remote invocation via the HttpInvokerRequestExecutor.
167+ * Execute the given remote invocation via the {@link HttpInvokerRequestExecutor} .
165168 * <p>This implementation delegates to {@link #executeRequest(RemoteInvocation)}.
166169 * Can be overridden to react to the specific original MethodInvocation.
167170 * @param invocation the RemoteInvocation to execute
@@ -177,7 +180,7 @@ protected RemoteInvocationResult executeRequest(
177180 }
178181
179182 /**
180- * Execute the given remote invocation via the HttpInvokerRequestExecutor.
183+ * Execute the given remote invocation via the {@link HttpInvokerRequestExecutor} .
181184 * <p>Can be overridden in subclasses to pass a different configuration object
182185 * to the executor. Alternatively, add further configuration properties in a
183186 * subclass of this accessor: By default, the accessor passed itself as
@@ -196,9 +199,10 @@ protected RemoteInvocationResult executeRequest(RemoteInvocation invocation) thr
196199
197200 /**
198201 * Convert the given HTTP invoker access exception to an appropriate
199- * Spring RemoteAccessException.
202+ * Spring {@link RemoteAccessException} .
200203 * @param ex the exception to convert
201- * @return the RemoteAccessException to throw
204+ * @return the RemoteAccessException to throw, or {@code null} to have the
205+ * original exception propagated to the caller
202206 */
203207 protected RemoteAccessException convertHttpInvokerAccessException (Throwable ex ) {
204208 if (ex instanceof ConnectException ) {
@@ -212,8 +216,13 @@ protected RemoteAccessException convertHttpInvokerAccessException(Throwable ex)
212216 "Could not deserialize result from HTTP invoker remote service [" + getServiceUrl () + "]" , ex );
213217 }
214218
215- return new RemoteAccessException (
219+ if (ex instanceof Exception ) {
220+ return new RemoteAccessException (
216221 "Could not access HTTP invoker remote service at [" + getServiceUrl () + "]" , ex );
222+ }
223+
224+ // For any other Throwable, e.g. OutOfMemoryError: let it get propagated as-is.
225+ return null ;
217226 }
218227
219228}
0 commit comments