Author: ron.sigal(a)jboss.com
Date: 2008-06-19 21:41:53 -0400 (Thu, 19 Jun 2008)
New Revision: 4301
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java
Log:
JBREM-960: (1) useHttpURLConnection() tries to add responseMessage and responseCode to
CannotConnectException(); (2) readResponse() checks for EOF on inputStream and throws
EOFException.
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java
===================================================================
---
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java 2008-06-20
01:35:20 UTC (rev 4300)
+++
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java 2008-06-20
01:41:53 UTC (rev 4301)
@@ -48,6 +48,7 @@
import org.jboss.util.threadpool.Task;
import org.jboss.util.threadpool.ThreadPool;
+import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -330,8 +331,21 @@
}
catch (Exception e)
{
- log.debug("Error invoking http client invoker.", e);
- throw new CannotConnectException("Can not connect http client
invoker.", e);
+ String message = "Can not connect http client invoker.";
+ if (e.getMessage() != null)
+ message += " " + e.getMessage() + ".";
+
+ try
+ {
+ String responseMessage = conn.getResponseMessage();
+ int code = conn.getResponseCode();
+ message += " Response: " + responseMessage + "/" + code +
".";
+ }
+ catch (IOException e1)
+ {
+ log.debug("Unable to retrieve response message", e1);
+ }
+ throw new CannotConnectException(message, e);
}
// now check for error response and throw exception unless configured to not do so
@@ -478,9 +492,9 @@
}
private Object readResponse(Map metadata, Map headers, UnMarshaller unmarshaller,
InputStream is)
- throws IOException, ClassNotFoundException
+ throws ClassNotFoundException, IOException
{
- Object result;
+ Object result = null;
String encoding = null;
Object ceObj = headers.get("Content-Encoding");
if (ceObj != null)
@@ -495,11 +509,26 @@
unmarshaller = new
CompressingUnMarshaller(MarshalFactory.getUnMarshaller(SerializableUnMarshaller.DATATYPE));
}
- Map map = metadata == null ? headers : metadata;
- if (unmarshaller instanceof VersionedUnMarshaller)
- result = ((VersionedUnMarshaller)unmarshaller).read(is, map,
Version.getDefaultVersion());
- else
- result = unmarshaller.read(is, map);
+ try
+ {
+ Map map = metadata == null ? headers : metadata;
+ if (unmarshaller instanceof VersionedUnMarshaller)
+ result = ((VersionedUnMarshaller)unmarshaller).read(is, map,
Version.getDefaultVersion());
+ else
+ result = unmarshaller.read(is, map);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw e;
+ }
+ catch (IOException e)
+ {
+ if (-1 == is.read())
+ {
+ throw new EOFException();
+ }
+ throw e;
+ }
return result;
}
Show replies by date