-
Notifications
You must be signed in to change notification settings - Fork 300
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
[JDBC 라이브러리 구현하기 - 4단계] 이오(이지우) 미션 제출합니다. #581
Conversation
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.
안녕하세요 이오~
리뷰가 늦었네요..!!
4단계도 요구사항에 맞게 깔끔하게 작성해주셔서 커멘트할 부분이 거의 없네요..!!
private final UserDao userDao; | ||
private final UserHistoryDao userHistoryDao; | ||
|
||
AppUserService(final UserDao userDao, final UserHistoryDao userHistoryDao) { |
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.
protected인 이유가 있나요?
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.
단순 실수입니다🥲 수정하였습니다! adbe25f
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.
오, 수정한 커밋 주시는거 너무 좋은데요?? :)
public static Connection unbindResource(DataSource key) { | ||
return null; | ||
public static Connection unbindResource(final DataSource key) { | ||
return resources.get().remove(key); |
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.
쓰레드로컬에 저장된 값은 지워주지 않아도 괜찮을까요?
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.
쓰레드 로컬에 저장된 값을 지운다는게 어떤 의미일까요? 잘 모르는 부분이라 어렵네요 🥲
우선 해당 부분은 UnbindResource를 한다는 것이 key로 받은 대상의 value를 remove 해주는 메소드라고 이해하여서 현재와 같이 구현하였습니다.
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.
쓰레드 로컬의 동작 원리에 대해 조금 검색해보면, Map에 쓰레드별로 리소스가 매핑되는 형태로 사용되는데요, 특정 쓰레드에서 어떠한 리소스를 사용한 뒤 이를 제거해주지 않으면, 이후 해당 쓰레드가 다른 사람에 의해 재사용될 때, 리소스가 그대로 남아있어 오작동을 일으킬 수도 있어요!
|
||
public TxUserService(final AppUserService appUserService) { | ||
this.appUserService = appUserService; | ||
this.transactionExecutor = new TransactionExecutor(DataSourceConfig.getInstance()); |
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.
생성자로 받지 않고 하드코딩하신 이유가 있나요?
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.
AppUserService에서 DataSource를 받지 않고 UserDao, UserHistoryDao를 받는 것 처럼 TxUserService도 AppUserService만 받는 것이 자연스럽다고 생각해서 이렇게 구현했었습니다! 미션 요구사항으로 부여받은 테스트코드에서도 TxUserService의 생성자엔 AppUserService만 있기도 했구요.
그런데 다시 보니 아예 TransactionExecutor를 외부에서 받는게 낫겠다는 생각이 드네요. 수정하겠습니다 :)
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.
:)
아이고 제가 리뷰요청 온걸 못 보고... |
안녕하세요 말랑, 이오입니다 :)
벌써 마지막 미션이네요! 4단계 리뷰도 잘부탁드립니다.
좋은 하루 보내세요!