You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cu...@apache.org on 2007/01/31 23:50:51 UTC
svn commit: r502030 - in /lucene/hadoop/trunk: CHANGES.txt
src/java/org/apache/hadoop/ipc/Client.java
src/java/org/apache/hadoop/ipc/Server.java
Author: cutting
Date: Wed Jan 31 14:50:50 2007
New Revision: 502030
URL: http://svn.apache.org/viewvc?view=rev&rev=502030
Log:
HADOOP-963. Fix remote exceptions to have the stack trace of the calling thread, not the IPC listener thread. Contributed by Owen.
Modified:
lucene/hadoop/trunk/CHANGES.txt
lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Client.java
lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Server.java
Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=502030&r1=502029&r2=502030
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Wed Jan 31 14:50:50 2007
@@ -125,6 +125,9 @@
38. HADOOP-549. Fix a NullPointerException in TaskReport's
serialization. (omalley via cutting)
+39. HADOOP-963. Fix remote exceptions to have the stack trace of the
+ caller thread, not the IPC listener thread. (omalley via cutting)
+
Release 0.10.1 - 2007-01-10
Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Client.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Client.java?view=diff&rev=502030&r1=502029&r2=502030
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Client.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Client.java Wed Jan 31 14:50:50 2007
@@ -77,7 +77,8 @@
int id; // call id
Writable param; // parameter
Writable value; // value, null if error
- RemoteException error; // error, null if value
+ String error; // exception, null if value
+ String errorClass; // class of exception
long lastActivity; // time of last i/o
boolean done; // true when call is done
@@ -101,9 +102,12 @@
}
/** Update lastActivity with the current time. */
- public synchronized void setResult(Writable value, RemoteException error) {
+ public synchronized void setResult(Writable value,
+ String errorClass,
+ String error) {
this.value = value;
this.error = error;
+ this.errorClass =errorClass;
this.done = true;
}
@@ -255,10 +259,8 @@
Call call = (Call)calls.remove(new Integer(id));
boolean isError = in.readBoolean(); // read if error
if (isError) {
- RemoteException ex =
- new RemoteException(WritableUtils.readString(in),
- WritableUtils.readString(in));
- call.setResult(null, ex);
+ call.setResult(null, WritableUtils.readString(in),
+ WritableUtils.readString(in));
} else {
Writable value = (Writable)ReflectionUtils.newInstance(valueClass, conf);
try {
@@ -267,7 +269,7 @@
} finally {
readingCall = null;
}
- call.setResult(value, null);
+ call.setResult(value, null, null);
}
call.callComplete(); // deliver result to caller
//received the response. So decrement the ref count
@@ -462,7 +464,7 @@
} while (!call.done && wait > 0);
if (call.error != null) {
- throw call.error;
+ throw new RemoteException(call.errorClass, call.error);
} else if (!call.done) {
throw new SocketTimeoutException("timed out waiting for rpc response");
} else {
Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Server.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Server.java?view=diff&rev=502030&r1=502029&r2=502030
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Server.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Server.java Wed Jan 31 14:50:50 2007
@@ -539,7 +539,7 @@
} catch (Throwable e) {
LOG.info(getName() + " call error: " + e, e);
errorClass = e.getClass().getName();
- error = getStackTrace(e);
+ error = StringUtils.stringifyException(e);
}
DataOutputStream out = call.connection.out;
@@ -569,14 +569,6 @@
}
}
LOG.info(getName() + ": exiting");
- }
-
- private String getStackTrace(Throwable throwable) {
- StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter(stringWriter);
- throwable.printStackTrace(printWriter);
- printWriter.flush();
- return stringWriter.toString();
}
}