Skip to content

Commit

Permalink
refactor: 이미 존재하는 Key일 경우 먼저 예외 발생하도록 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
sh111-coder committed Oct 11, 2023
1 parent 9ea5497 commit 0cde77e
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ public static void bindResource(DataSource key, Connection value) {
resources.set(connectionMap);
}

Connection mappedConnection = connectionMap.put(key, value);
if (mappedConnection != null) {
if (connectionMap.containsKey(key)) {
throw new IllegalStateException("fail to bind resource because of already exist bound thread");
}

connectionMap.put(key, value);
}

public static Connection unbindResource(DataSource key) {
Expand Down

0 comments on commit 0cde77e

Please sign in to comment.