Hooking up a couple of missing cause chains in the server-side RPC exception handling code.

Also added a hack to dump a particular exception case to the console, to help us debug
an intermittent RPC test failure condition.

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@5183 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/rpc/impl/RequestCallbackAdapter.java b/user/src/com/google/gwt/user/client/rpc/impl/RequestCallbackAdapter.java
index e963da9..af73dad 100644
--- a/user/src/com/google/gwt/user/client/rpc/impl/RequestCallbackAdapter.java
+++ b/user/src/com/google/gwt/user/client/rpc/impl/RequestCallbackAdapter.java
@@ -201,7 +201,8 @@
         caught = new InvocationException(encodedResponse);
       }
     } catch (com.google.gwt.user.client.rpc.SerializationException e) {
-      caught = new IncompatibleRemoteServiceException();
+      caught = new IncompatibleRemoteServiceException(
+          "The response could not be deserialized", e);
     } catch (Throwable e) {
       caught = e;
     } finally {
diff --git a/user/src/com/google/gwt/user/server/rpc/impl/ServerSerializationStreamReader.java b/user/src/com/google/gwt/user/server/rpc/impl/ServerSerializationStreamReader.java
index 3dfc3d9..c4e7d61 100644
--- a/user/src/com/google/gwt/user/server/rpc/impl/ServerSerializationStreamReader.java
+++ b/user/src/com/google/gwt/user/server/rpc/impl/ServerSerializationStreamReader.java
@@ -537,8 +537,20 @@
       throw new SerializationException(e);
 
     } catch (InvocationTargetException e) {
-      throw new SerializationException(e);
+      /*
+       * HACK(scottb): temporary hack to print internal exceptions to the
+       * console while we try to pin down a flaky RPC test that fails very
+       * intermittently. The stack trace gets lost when we send this server
+       * exception back to the client, because we currently don't serialize
+       * cause and stacktrace across the wire. We end up with a useless
+       * client-side stacktrace that has no cause, and that's what JUnit sees.
+       * We can remove this spam if we serialize cause/stacktrace back to the
+       * client even if we haven't yet solve the flaky RPC test issue.
+       */
+      e.getTargetException().printStackTrace(System.out);
+      e.getTargetException().printStackTrace(System.err);
 
+      throw new SerializationException(e.getTargetException());
     } catch (NoSuchMethodException e) {
       throw new SerializationException(e);
     }