-
Notifications
You must be signed in to change notification settings - Fork 379
[4단계 - Transaction synchronization 적용하기] 한스(이현수) 미션 제출합니다. #1168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 20hyeonsulee
Are you sure you want to change the base?
Conversation
Warning Rate limit exceeded@20HyeonsuLee has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 30 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (9)
요약이 변경사항은 수동 JDBC 기반 데이터 액세스를 JdbcTemplate 기반으로 마이그레이션하는 포괄적인 리팩토링입니다. UserDao와 UserHistoryDao를 JdbcTemplate을 사용하도록 업데이트하고, 조회 메서드의 반환 타입을 Optional로 변경했습니다. UserService는 DataSource를 추가로 수용하여 명시적 트랜잭션 관리를 지원합니다. JdbcTemplate에 매개변수화된 쿼리와 행 매핑을 위한 새로운 공개 API 메서드를 추가했고, RowMapper 인터페이스를 도입했습니다. 테스트 인프라를 업데이트하고 DatabaseInitializer 유틸리티 클래스를 추가했으며, JUnit 5 의존성을 포함시켰습니다. Pre-merge checks❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세요 한스~ Step4 멋진 코드 잘 봤습니다! hasConnection
으로 먼저 커넥션을 확인한 후 로직 진행하는 부분 배워갑니다 ㅎㅎ
추가적으로 리뷰 남겼으니 한번 확인해주시죠! 또 더 의논하고 싶은 부분이 있다면 말씀해주세요.
수고하셨습니다!
if (resources.get() == null) { | ||
resources.set(new HashMap<>()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P5: LocalThread에는 최초 선언시 값을 초기화 할 수 있는 함수가 있는 것 같아요. 대신 사용해보면 어떨까요??
try { | ||
connection.rollback(); | ||
} catch (SQLException ex) { | ||
throw new RuntimeException(ex); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: 이 부분에서 rollback 시 예외가 발생한다면 원본 예외(Exception e)가 덮어 씌워지는데 어떤가요? 만약 changePassword
에서 NPE가 발생하고, 롤백 시 예외가 발생한다면 NPE는 알 수 없게 될 것 같아요.
|
||
public void changePassword(final long id, final String newPassword, final String createBy) { | ||
final DataSource dataSource = DataSourceConfig.getInstance(); | ||
final Connection connection = DataSourceUtils.getConnection(dataSource); | ||
try { | ||
connection.setAutoCommit(false); | ||
userService.changePassword(id, newPassword, createBy); | ||
connection.commit(); | ||
} catch (Exception e) { | ||
try { | ||
connection.rollback(); | ||
} catch (SQLException ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
throw new DataAccessException(e); | ||
} finally { | ||
DataSourceUtils.releaseConnection(connection, dataSource); | ||
TransactionSynchronizationManager.unbindResource(dataSource); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P5: 이 코드의 종착지는 아시죠? AOP도 배워봤으니, 시간 되실때 어노테이션으로 구현해보는것도 추천드립니다. 이번주는 바쁘니 넘어가시죠 ㅎㅎ
안녕하세요 아마~
이번에도 리뷰 잘부탁드립니다!