Skip to content

Embedded database connection closed by shutdown() method [SPR-11372] #15999

@spring-projects-issues

Description

@spring-projects-issues

Phil Webb opened SPR-11372 and commented

Spring Batch recently hit a very hard to track-down problem when upgrading from Spring 3.2.0 to 3.2.7.

When running the entire test suite some tests fail with the following exception:

java.sql.SQLNonTransientConnectionException: connection exception: closed

Running tests in isolation causes no problems.

The minimum suite that replicates the issue is:

@RunWith(Suite.class)
@SuiteClasses({
SimpleJobRepositoryIntegrationTests.class,
JobBuilderConfigurationTests.class,
ChunkOrientedStepIntegrationTests.class })
public class ReproTests {
}

After a lot of digging it appears that the root cause of the failure is #14347 [1].

Here is what happens:

SimpleJobRepositoryIntegrationTests uses spring-test and includes a commons-dbcp data-source. The data-source is part of a config that is cached.

JobBuilderConfigurationTests creates a direct EmbeddedDataSource. Tests here do not use spring-test. When the context is closed the shutdown method is called on the EmbeddedDataSource. This in turn issues some SQL that actually closes the HSQLDB session.

ChunkOrientedStepIntegrationTests runs, and reuses the previously created commons-dbcp pool. The pool appears to be open but because the entire session has been shutdown interaction cause exceptions.

[1] 4c823a3


Affects: 3.2 GA, 4.0 GA

Issue Links:

1 votes, 7 watchers

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: bulk-closedAn outdated, unresolved issue that's closed in bulk as part of a cleaning process

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions