Work around JDK7 String#substring performance regression

String#substring has become significantly slower as of JDK 1.7.0_06 [1],
such that there are performance degradations by a factor of 100-1000 in
ResourceDatabasePopulator, especially for large SQL files.

This commit works around this problem by minimizing the substring scope
to the least amount possible to prevent unnecessary internal copying of
strings (which seems to cause the issue).

[1]: http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-May/010257.html

Issue: SPR-9781
This commit is contained in:
Oliver Gierke
2012-09-11 12:51:27 +02:00
committed by Chris Beams
parent dfe05305e2
commit 3fb3b7d67a
3 changed files with 2057 additions and 5 deletions

View File

@@ -238,4 +238,21 @@ public class DatabasePopulatorTests {
EasyMock.verify(populator);
}
/**
* @see SPR-9781
*/
@Test(timeout = 1000)
public void executesHugeScriptInReasonableTime() throws SQLException {
databasePopulator.addScript(resourceLoader.getResource("db-schema.sql"));
databasePopulator.addScript(resourceLoader.getResource("db-test-data-huge.sql"));
Connection connection = db.getConnection();
try {
databasePopulator.populate(connection);
} finally {
connection.close();
}
}
}