[jboss-svn-commits] JBL Code SVN: r26617 - in labs/jbossesb/trunk/product/rosetta: tests/src/org/jboss/soa/esb/actions/routing/http and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue May 19 08:34:33 EDT 2009
Author: beve
Date: 2009-05-19 08:34:33 -0400 (Tue, 19 May 2009)
New Revision: 26617
Modified:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpRouter.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/http/HttpRouterUnitTest.java
Log:
Work for https://jira.jboss.org/jira/browse/JBESB-2525 "HttpRouter fire java.lang.NullPointerException if the Response is empty (204)"
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpRouter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpRouter.java 2009-05-19 12:17:17 UTC (rev 26616)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpRouter.java 2009-05-19 12:34:33 UTC (rev 26617)
@@ -35,6 +35,7 @@
import org.jboss.soa.esb.message.Message;
import org.jboss.internal.soa.esb.util.StreamUtils;
+import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
@@ -115,7 +116,7 @@
} catch (MessageDeliverException e) {
e.printStackTrace();
} finally {
- resultStream.close();
+ closeStream(resultStream);
}
} finally {
method.releaseConnection();
@@ -127,6 +128,12 @@
return message;
}
+ void closeStream(final Closeable c) throws IOException {
+ if (c != null) {
+ c.close();
+ }
+ }
+
private String[] extractMappedHeaderListConfig() throws ConfigurationException {
final String mappedHeaders = config.getAttribute("MappedHeaderList");
if (mappedHeaders != null) {
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/http/HttpRouterUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/http/HttpRouterUnitTest.java 2009-05-19 12:17:17 UTC (rev 26616)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/http/HttpRouterUnitTest.java 2009-05-19 12:34:33 UTC (rev 26617)
@@ -22,15 +22,20 @@
package org.jboss.soa.esb.actions.routing.http;
+import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import junit.framework.JUnit4TestAdapter;
import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionProcessingException;
import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
import org.junit.Before;
import org.junit.Test;
@@ -76,6 +81,25 @@
assertEquals(0, headers.size());
}
+ @Test
+ public void testRouter_NullResponse() throws ConfigurationException, ActionProcessingException
+ {
+ final ConfigTree tree = new ConfigTree("ValidMappedHeaderList");
+ tree.setAttribute("endpointUrl", "http://foo.bar");
+ tree.setAttribute("method", "post");
+ tree.setAttribute("MappedHeaderList", "SOAPAction, Content-Type, Accept");
+
+ HttpRouter router = new HttpRouter(tree);
+ try
+ {
+ router.closeStream(null);
+ }
+ catch (final IOException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
public static junit.framework.Test suite() {
return new JUnit4TestAdapter(HttpRouterUnitTest.class);
}
More information about the jboss-svn-commits
mailing list