Skip to content

Commit

Permalink
Allocate objects only when it's necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
stsypanov authored and sbrannen committed May 27, 2019
1 parent 6f2f5bb commit 6964ed3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,12 @@ private KeyHolder executeInsertAndReturnKeyHolderInternal(final List<?> values)
//Get the key
Statement keyStmt = null;
ResultSet rs = null;
Map<String, Object> keys = new HashMap<>(2);
try {
keyStmt = con.createStatement();
rs = keyStmt.executeQuery(keyQuery);
if (rs.next()) {
long key = rs.getLong(1);
Map<String, Object> keys = new HashMap<>(2);
keys.put(getGeneratedKeyNames()[0], key);
keyHolder.getKeyList().add(keys);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ protected String[] generateDefaultLocations(Class<?> clazz) {
for (String suffix : suffixes) {
Assert.hasText(suffix, "Resource suffix must not be empty");
String resourcePath = ClassUtils.convertClassNameToResourcePath(clazz.getName()) + suffix;
String prefixedResourcePath = ResourceUtils.CLASSPATH_URL_PREFIX + resourcePath;
ClassPathResource classPathResource = new ClassPathResource(resourcePath);
if (classPathResource.exists()) {
String prefixedResourcePath = ResourceUtils.CLASSPATH_URL_PREFIX + resourcePath;
if (logger.isInfoEnabled()) {
logger.info(String.format("Detected default resource location \"%s\" for test class [%s]",
prefixedResourcePath, clazz.getName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ public String toString() {
*/
private static String detectDefaultPropertiesFile(Class<?> testClass) {
String resourcePath = ClassUtils.convertClassNameToResourcePath(testClass.getName()) + ".properties";
String prefixedResourcePath = ResourceUtils.CLASSPATH_URL_PREFIX + resourcePath;
ClassPathResource classPathResource = new ClassPathResource(resourcePath);

if (classPathResource.exists()) {
String prefixedResourcePath = ResourceUtils.CLASSPATH_URL_PREFIX + resourcePath;
if (logger.isInfoEnabled()) {
logger.info(String.format("Detected default properties file \"%s\" for test class [%s]",
prefixedResourcePath, testClass.getName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,11 +637,11 @@ protected final void resume(@Nullable Object transaction, @Nullable SuspendedRes
private void resumeAfterBeginException(
Object transaction, @Nullable SuspendedResourcesHolder suspendedResources, Throwable beginEx) {

String exMessage = "Inner transaction begin exception overridden by outer transaction resume exception";
try {
resume(transaction, suspendedResources);
}
catch (RuntimeException | Error resumeEx) {
String exMessage = "Inner transaction begin exception overridden by outer transaction resume exception";
logger.error(exMessage, beginEx);
throw resumeEx;
}
Expand Down

0 comments on commit 6964ed3

Please sign in to comment.