(0003260)
lizongbo
07-12-08 10:33
edited on: 07-12-08 10:37
|
in 3.1.6 also have the bug ,the cause of is that:
when you use hession 2.0 by Hessian2Output&12290;
then when get HessianMetaInfoAPI or got an Exception ,Hessian2Output 's out method not executed .
so I fix the bug by an "out.cloes();" fro every "return;" in "invoke" method .
the code ifs follow:
-----------------------------
public void invoke(Object service,
AbstractHessianInput in,
AbstractHessianOutput out) throws Exception {
ServiceContext context = ServiceContext.getContext();
// backward compatibility for some frameworks that don't read
// the call type first
in.skipOptionalCall();
String header;
while ((header = in.readHeader()) != null) {
Object value = in.readObject();
context.addHeader(header, value);
}
String methodName = in.readMethod();
Method method = getMethod(methodName);
if (method != null) {
} else if ("_hessian_getAttribute".equals(methodName)) {
String attrName = in.readString();
in.completeCall();
String value = null;
if ("java.api.class".equals(attrName)) {
value = getAPIClassName();
} else if ("java.home.class".equals(attrName)) {
value = getHomeClassName();
} else if ("java.object.class".equals(attrName)) {
value = getObjectClassName();
}
out.startReply();
out.writeObject(value);
out.completeReply();
out.close();// fix bug for Hessian2Output,added by lizongbo
return;
} else if (method == null) {
out.startReply();
out.writeFault("NoSuchMethodException",
"The service has no method named: " + in.getMethod(),
null);
out.completeReply();
out.close();// fix bug for Hessian2Output,added by lizongbo
return;
}
Class[] args = method.getParameterTypes();
Object[] values = new Object[args.length];
for (int i = 0; i < args.length; i++) {
values[i] = in.readObject(args[i]);
}
Object result = null;
try {
result = method.invoke(service, values);
} catch (Throwable e) {
if (e instanceof InvocationTargetException) {
e = ((InvocationTargetException) e).getTargetException();
}
log.log(Level.WARNING, e.toString(), e);
out.startReply();
out.writeFault("ServiceException", e.getMessage(), e);
out.completeReply();
out.close();// fix bug for Hessian2Output,added by lizongbo
return;
}
// The complete call needs to be after the invoke to handle a
// trailing InputStream
in.completeCall();
out.startReply();
out.writeObject(result);
out.completeReply();
out.close();
}
----------------------
|