Skip to content

Commit

Permalink
refactor: finally 블록 예외 시 로깅 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
junpakPark committed Oct 15, 2023
1 parent c58d27d commit 697db42
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ public static void execute(final DataSource dataSource) {
if (statement != null) {
statement.close();
}
} catch (SQLException ignored) {}
} catch (SQLException e) {
log.warn(String.valueOf(e));
}

try {
if (connection != null) {
connection.close();
}
} catch (SQLException ignored) {}
} catch (SQLException e) {
log.warn(String.valueOf(e));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
import java.sql.SQLException;
import java.util.function.Supplier;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.datasource.DataSourceUtils;
import org.springframework.transaction.TransactionException;

public class TransactionManager {

private static final Logger log = LoggerFactory.getLogger(TransactionManager.class);

private final DataSource dataSource;

public TransactionManager(DataSource dataSource) {
Expand Down Expand Up @@ -75,7 +79,7 @@ private void release(Connection connection) {
DataSourceUtils.releaseConnection(connection, dataSource);
TransactionSynchronizationManager.unbindResource(dataSource);
} catch (Exception e) {
throw new TransactionException(e);
log.warn(String.valueOf(e));
}
}

Expand Down

0 comments on commit 697db42

Please sign in to comment.