Author: ron.sigal(a)jboss.com
Date: 2008-11-13 17:35:36 -0500 (Thu, 13 Nov 2008)
New Revision: 4675
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java
Log:
JBREM-1052: Added unmarshalNullStream variable and related test.
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-11-13
06:58:23 UTC (rev 4674)
+++
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java 2008-11-13
22:35:36 UTC (rev 4675)
@@ -92,19 +92,29 @@
*/
public static final int MAX_NUM_TIMEOUT_THREADS_DEFAULT = 10;
+ /*
+ * Specifies whether useHttpURLConnection(), upon receiving a null InputStream or
ErrorStream,
+ * should call the UnMarshaller.
+ */
+ public static final String UNMARSHAL_NULL_STREAM = "unmarshalNullStream";
+
protected static final Logger log = Logger.getLogger(HTTPClientInvoker.class);
+ protected boolean unmarshalNullStream = true;
+
private Object timeoutThreadPoolLock = new Object();
private ThreadPool timeoutThreadPool;
public HTTPClientInvoker(InvokerLocator locator)
{
super(locator);
+ configureParameters();
}
public HTTPClientInvoker(InvokerLocator locator, Map configuration)
{
super(locator, configuration);
+ configureParameters();
}
/**
@@ -280,7 +290,7 @@
else
marshaller.write(invocation, stream);
responseCode = conn.getResponseCode();
- InputStream is = (responseCode < 400) ? conn.getInputStream() :
conn.getErrorStream();
+
Map headers = conn.getHeaderFields();
if (metadata == null)
{
@@ -304,7 +314,11 @@
metadata.put(HTTPMetadataConstants.RESPONSE_CODE_MESSAGE,
conn.getResponseMessage());
metadata.put(HTTPMetadataConstants.RESPONSE_CODE, new
Integer(responseCode));
- result = readResponse(metadata, headers, unmarshaller, is);
+ InputStream is = (responseCode < 400) ? conn.getInputStream() :
conn.getErrorStream();
+ if (is != null || unmarshalNullStream)
+ {
+ result = readResponse(metadata, headers, unmarshaller, is);
+ }
}
else
{
@@ -317,8 +331,11 @@
InputStream is = (conn.getResponseCode() < 400) ? conn.getInputStream() :
conn.getErrorStream();
Map headers = conn.getHeaderFields();
- result = readResponse(null, headers, unmarshaller, is);
-
+ if (is != null || unmarshalNullStream)
+ {
+ result = readResponse(null, headers, unmarshaller, is);
+ }
+
if (metadata == null)
{
metadata = new HashMap();
@@ -880,6 +897,25 @@
this.timeoutThreadPool = pool;
}
+ protected void configureParameters()
+ {
+ Object val = configuration.get(UNMARSHAL_NULL_STREAM);
+ if (val != null)
+ {
+ try
+ {
+ unmarshalNullStream = Boolean.valueOf((String)val).booleanValue();
+ log.debug(this + " setting unmarshalNullStream to " +
unmarshalNullStream);
+ }
+ catch (Exception e)
+ {
+ log.warn(this + " could not convert " +
+ UNMARSHAL_NULL_STREAM + " value of " +
+ val + " to a boolean value.");
+ }
+ }
+ }
+
/**
* Gets the thread pool being used for simulating timeouts with jdk 1.4. If one has
* not be specifically set via configuration or call to set it, will always return
Show replies by date