Issue 1:
Juan Antonio Farré Basurte opened SPR-8123 and commented

I've noticed that SimpleClientHttpResponse.close() (which it is documented you MUST always call it after completing the request) invokes HttpURLConnection.disconnect() for the wrapped connection.

JDK javadoc for HttpURLConnection states the following:

Calling the close() methods on the InputStream or OutputStream of an HttpURLConnection after a request may free network resources associated with this instance but has no effect on any shared persistent connection. Calling the disconnect() method may close the underlying socket if a persistent connection is otherwise idle at that time.

So, when you close SimpleClientHttpResponse you may be disconnecting the underlying socket for a connection that could otherwise be reused (not the HttpURLConnection instance itself, but the underlying socket connection).

I believe close should close any open InputStreams (if either HttpURLConnection.getErrorStream() or URLConnection.getInputStream() were invoked), but not invoke the disconnect method.

If such functionality is required to be available for users of SimpleHttpUrlConnection, then I believe a new method should be added (for example disconnect()) that is not required to be called.

Thanks,

Juan

Affects: 3.0.5

Issue Links:

#18612 HTTP persistent connections for HTTP Invoker and RestTemplate ("duplicates")

#21717 SimpleClientHttpResponse.close() does not call close() on URLConnection.getInputStream() if SimpleClientHttpResponse.getBody() was not called before

Issue 2:
Mike Youngstrom opened SPR-2359 and commented

I'm trying out 2.0 rc3-SNAPSHOT build 88. I'm running a webapp using Eclipse WTP. The application works fine with RC1. When I upgraded to the SNAPSHOT everything continues to work fine when I launch my server in non degug mode. But when I launch my server in debug mode I get a StackOverflowError. I know my problem sounds suspect but I can switch my version of spring from RC1 to RC3-SNAPSHOT and consistently have no error with RC1 and always get the stackoverflow error with the RC3-SNAPSHOT build 88. Below is the stacktrace, serviceLoader.xml, and a snippet of web.xml. All other context files are empty. By setting a break point in the middle of the findPathMatchingResources loop I can see the resource it is trying to resolve is the "classpath*:/service-context/**/*Context.xml" of serviceContext.

--------------------------web.xml snippet--------------------

<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>

/WEB-INF/view-context/**/*Context.xml

</param-value>

</context-param>

<context-param>

<param-name>locatorFactorySelector</param-name>

<param-value>

classpath*:/org/lds/stack/service/serviceLoader.xml

</param-value>

</context-param>

<context-param>

<param-name>parentContextKey</param-name>

<param-value>serviceContext</param-value>

</context-param>

--------------serviceLoader.xml--------------------------

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<!-- Application context for Service layer of app. Created to help stop leaking of Web layer spring beans
Into Service layer. Should never have to modify this file.-->
<bean id="serviceContext" lazy-init="true"
class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg>
<list>
<!-- all the XML files to include in a default application's service application Context. -->
<value>classpath*:/service-context/**/*Context.xml</value>
</list>
</constructor-arg>
</bean>

</beans>

--------------------------Stacktrace-------------------------------

09:42:46,156 ERROR ContextLoader: Context initialization failed

org.springframework.beans.factory.access.BootstrapException: Unable to return specified BeanFactory instance: factory key [serviceContext], from group with resource name [classpath*:/org/lds/stack/service/serviceLoader.xml]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceContext' defined in URL [jar:file:/C:/projects/Stack/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/joe/WEB-INF/lib/stack-code-2.0-SNAPSHOT.jar!/org/lds/stack/service/serviceLoader.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is java.lang.StackOverflowError

Caused by:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceContext' defined in URL [jar:file:/C:/projects/Stack/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/joe/WEB-INF/lib/stack-code-2.0-SNAPSHOT.jar!/org/lds/stack/service/serviceLoader.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is java.lang.StackOverflowError

Caused by:

org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is java.lang.StackOverflowError

Caused by:

java.lang.StackOverflowError

at java.lang.String.indexOf(String.java:1564)

at java.lang.String.indexOf(String.java:1546)

at org.springframework.core.io.support.PathMatchingResourcePatternResolver.determineRootDir(PathMatchingResourcePatternResolver.java:353)

at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:321)

at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:265)

at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:323)

at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:265)

at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:323)

at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:265)

at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:323)

at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:265)

at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:323)

at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:265)

at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:323)

at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:265)

Affects: 2.0 RC3

Attachments:

TestClassPathXmlApplicationContext.zip (3.32 kB)