The RPC refactoring for issue 389 which was committed at r677 contained a couple of Java 1.5 only features. This patch makes the RPC code compliant with the 1.4 JRE. All unit tests passed.
Review by: scottb
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@686 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/javadoc/com/google/gwt/examples/rpc/server/AdvancedExample.java b/user/javadoc/com/google/gwt/examples/rpc/server/AdvancedExample.java
index b454200..632acc6 100644
--- a/user/javadoc/com/google/gwt/examples/rpc/server/AdvancedExample.java
+++ b/user/javadoc/com/google/gwt/examples/rpc/server/AdvancedExample.java
@@ -66,12 +66,17 @@
sendResponseForSuccess(httpResponse, encodedResult);
} catch (IllegalArgumentException e) {
- throw new SecurityException("Blocked attempt to invoke method "
- + targetMethod, e);
+ SecurityException securityException = new SecurityException(
+ "Blocked attempt to invoke method " + targetMethod);
+ securityException.initCause(e);
+ throw securityException;
} catch (IllegalAccessException e) {
- throw new SecurityException("Blocked attempt to access inaccessible method "
- + targetMethod
- + (targetInstance != null ? " on target " + targetInstance : ""), e);
+ SecurityException securityException = new SecurityException(
+ "Blocked attempt to access inaccessible method "
+ + targetMethod
+ + (targetInstance != null ? " on target " + targetInstance : ""));
+ securityException.initCause(e);
+ throw securityException;
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
diff --git a/user/src/com/google/gwt/user/server/rpc/RPC.java b/user/src/com/google/gwt/user/server/rpc/RPC.java
index 741ad53..751af11 100644
--- a/user/src/com/google/gwt/user/server/rpc/RPC.java
+++ b/user/src/com/google/gwt/user/server/rpc/RPC.java
@@ -201,8 +201,11 @@
+ "', which doesn't extend RemoteService; this is either misconfiguration or a hack attempt");
}
} catch (ClassNotFoundException e) {
- throw new SecurityException("Could not locate requested interface '"
- + serviceIntfName + "' in default classloader", e);
+ SecurityException securityException = new SecurityException(
+ "Could not locate requested interface '" + serviceIntfName
+ + "' in default classloader");
+ securityException.initCause(e);
+ throw securityException;
}
String serviceMethodName = streamReader.readString();
@@ -345,11 +348,15 @@
responsePayload = encodeResponseForSuccess(serviceMethod, result);
} catch (IllegalAccessException e) {
- throw new SecurityException(formatIllegalAccessErrorMessage(target,
- serviceMethod), e);
+ SecurityException securityException = new SecurityException(
+ formatIllegalAccessErrorMessage(target, serviceMethod));
+ securityException.initCause(e);
+ throw securityException;
} catch (IllegalArgumentException e) {
- throw new SecurityException(formatIllegalArgumentErrorMessage(target,
- serviceMethod, args), e);
+ SecurityException securityException = new SecurityException(
+ formatIllegalArgumentErrorMessage(target, serviceMethod, args));
+ securityException.initCause(e);
+ throw securityException;
} catch (InvocationTargetException e) {
// Try to encode the caught exception
//
diff --git a/user/test/com/google/gwt/user/server/rpc/RPCTest.java b/user/test/com/google/gwt/user/server/rpc/RPCTest.java
index d6ec304..08cb883 100644
--- a/user/test/com/google/gwt/user/server/rpc/RPCTest.java
+++ b/user/test/com/google/gwt/user/server/rpc/RPCTest.java
@@ -243,7 +243,7 @@
try {
String str = RPC.encodeResponseForFailure(A.class.getMethod("method1",
null), new SerializableException());
- assertTrue(str.contains("SerializableException"));
+ assertTrue(str.indexOf("SerializableException") != -1);
} catch (Throwable e) {
fail(e.getMessage());
}