Skip to content

Commit 6964ed3

Browse files
stsypanovsbrannen
authored andcommitted
Allocate objects only when it's necessary
Closes gh-23036
1 parent 6f2f5bb commit 6964ed3

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,12 +484,12 @@ private KeyHolder executeInsertAndReturnKeyHolderInternal(final List<?> values)
484484
//Get the key
485485
Statement keyStmt = null;
486486
ResultSet rs = null;
487-
Map<String, Object> keys = new HashMap<>(2);
488487
try {
489488
keyStmt = con.createStatement();
490489
rs = keyStmt.executeQuery(keyQuery);
491490
if (rs.next()) {
492491
long key = rs.getLong(1);
492+
Map<String, Object> keys = new HashMap<>(2);
493493
keys.put(getGeneratedKeyNames()[0], key);
494494
keyHolder.getKeyList().add(keys);
495495
}

spring-test/src/main/java/org/springframework/test/context/support/AbstractContextLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ protected String[] generateDefaultLocations(Class<?> clazz) {
245245
for (String suffix : suffixes) {
246246
Assert.hasText(suffix, "Resource suffix must not be empty");
247247
String resourcePath = ClassUtils.convertClassNameToResourcePath(clazz.getName()) + suffix;
248-
String prefixedResourcePath = ResourceUtils.CLASSPATH_URL_PREFIX + resourcePath;
249248
ClassPathResource classPathResource = new ClassPathResource(resourcePath);
250249
if (classPathResource.exists()) {
250+
String prefixedResourcePath = ResourceUtils.CLASSPATH_URL_PREFIX + resourcePath;
251251
if (logger.isInfoEnabled()) {
252252
logger.info(String.format("Detected default resource location \"%s\" for test class [%s]",
253253
prefixedResourcePath, clazz.getName()));

spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceAttributes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ public String toString() {
156156
*/
157157
private static String detectDefaultPropertiesFile(Class<?> testClass) {
158158
String resourcePath = ClassUtils.convertClassNameToResourcePath(testClass.getName()) + ".properties";
159-
String prefixedResourcePath = ResourceUtils.CLASSPATH_URL_PREFIX + resourcePath;
160159
ClassPathResource classPathResource = new ClassPathResource(resourcePath);
161160

162161
if (classPathResource.exists()) {
162+
String prefixedResourcePath = ResourceUtils.CLASSPATH_URL_PREFIX + resourcePath;
163163
if (logger.isInfoEnabled()) {
164164
logger.info(String.format("Detected default properties file \"%s\" for test class [%s]",
165165
prefixedResourcePath, testClass.getName()));

spring-tx/src/main/java/org/springframework/transaction/support/AbstractPlatformTransactionManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,11 +637,11 @@ protected final void resume(@Nullable Object transaction, @Nullable SuspendedRes
637637
private void resumeAfterBeginException(
638638
Object transaction, @Nullable SuspendedResourcesHolder suspendedResources, Throwable beginEx) {
639639

640-
String exMessage = "Inner transaction begin exception overridden by outer transaction resume exception";
641640
try {
642641
resume(transaction, suspendedResources);
643642
}
644643
catch (RuntimeException | Error resumeEx) {
644+
String exMessage = "Inner transaction begin exception overridden by outer transaction resume exception";
645645
logger.error(exMessage, beginEx);
646646
throw resumeEx;
647647
}

0 commit comments

Comments
 (0)