@@ -140,12 +140,15 @@ public Object invoke(MethodInvocation methodInvocation) throws Throwable {
140
140
141
141
RemoteInvocation invocation = createRemoteInvocation (methodInvocation );
142
142
RemoteInvocationResult result ;
143
+
143
144
try {
144
145
result = executeRequest (invocation , methodInvocation );
145
146
}
146
147
catch (Throwable ex ) {
147
- throw convertHttpInvokerAccessException (ex );
148
+ RemoteAccessException rae = convertHttpInvokerAccessException (ex );
149
+ throw (rae != null ? rae : ex );
148
150
}
151
+
149
152
try {
150
153
return recreateRemoteInvocationResult (result );
151
154
}
@@ -161,7 +164,7 @@ public Object invoke(MethodInvocation methodInvocation) throws Throwable {
161
164
}
162
165
163
166
/**
164
- * Execute the given remote invocation via the HttpInvokerRequestExecutor.
167
+ * Execute the given remote invocation via the {@link HttpInvokerRequestExecutor} .
165
168
* <p>This implementation delegates to {@link #executeRequest(RemoteInvocation)}.
166
169
* Can be overridden to react to the specific original MethodInvocation.
167
170
* @param invocation the RemoteInvocation to execute
@@ -177,7 +180,7 @@ protected RemoteInvocationResult executeRequest(
177
180
}
178
181
179
182
/**
180
- * Execute the given remote invocation via the HttpInvokerRequestExecutor.
183
+ * Execute the given remote invocation via the {@link HttpInvokerRequestExecutor} .
181
184
* <p>Can be overridden in subclasses to pass a different configuration object
182
185
* to the executor. Alternatively, add further configuration properties in a
183
186
* subclass of this accessor: By default, the accessor passed itself as
@@ -196,9 +199,10 @@ protected RemoteInvocationResult executeRequest(RemoteInvocation invocation) thr
196
199
197
200
/**
198
201
* Convert the given HTTP invoker access exception to an appropriate
199
- * Spring RemoteAccessException.
202
+ * Spring {@link RemoteAccessException} .
200
203
* @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
202
206
*/
203
207
protected RemoteAccessException convertHttpInvokerAccessException (Throwable ex ) {
204
208
if (ex instanceof ConnectException ) {
@@ -212,8 +216,13 @@ protected RemoteAccessException convertHttpInvokerAccessException(Throwable ex)
212
216
"Could not deserialize result from HTTP invoker remote service [" + getServiceUrl () + "]" , ex );
213
217
}
214
218
215
- return new RemoteAccessException (
219
+ if (ex instanceof Exception ) {
220
+ return new RemoteAccessException (
216
221
"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 ;
217
226
}
218
227
219
228
}
0 commit comments