Skip to content

Commit c7f91ac

Browse files
author
github-actions
committed
chore: Java 스타일 수정
1 parent 82d1731 commit c7f91ac

File tree

8 files changed

+430
-347
lines changed

8 files changed

+430
-347
lines changed

backend/src/main/java/io/f1/backend/domain/game/app/RoomService.java

Lines changed: 170 additions & 145 deletions
Large diffs are not rendered by default.

backend/src/main/java/io/f1/backend/domain/game/websocket/controller/GameSocketController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public void initializeRoomSocket(@DestinationVariable Long roomId, Message<?> me
3939
public void reconnect(@DestinationVariable Long roomId, Message<?> message) {
4040

4141
UserPrincipal principal = getSessionUser(message);
42-
roomService.changeConnectedStatusWithLock(roomId, principal.getUserId(), ConnectionState.CONNECTED);
42+
roomService.changeConnectedStatusWithLock(
43+
roomId, principal.getUserId(), ConnectionState.CONNECTED);
4344
roomService.reconnectSendResponseWithLock(roomId, principal);
4445
}
4546

backend/src/main/java/io/f1/backend/domain/game/websocket/eventlistener/WebsocketEventListener.java

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import io.f1.backend.domain.game.websocket.DisconnectTaskManager;
1010
import io.f1.backend.domain.game.websocket.HeartbeatMonitor;
1111
import io.f1.backend.domain.user.dto.UserPrincipal;
12-
1312
import io.f1.backend.global.lock.LockExecutor;
13+
1414
import lombok.RequiredArgsConstructor;
1515
import lombok.extern.slf4j.Slf4j;
1616

@@ -45,24 +45,29 @@ public void handleDisconnectedListener(SessionDisconnectEvent event) {
4545
return;
4646
}
4747

48-
Long roomId = lockExecutor.executeWithLock(USER_LOCK_PREFIX, userId,
49-
() -> roomService.getRoomIdByUserId(userId));
48+
Long roomId =
49+
lockExecutor.executeWithLock(
50+
USER_LOCK_PREFIX, userId, () -> roomService.getRoomIdByUserId(userId));
5051

5152
lockExecutor.executeWithLock(
52-
ROOM_LOCK_PREFIX, roomId, () -> roomService.changeConnectedStatus(roomId, userId,
53-
ConnectionState.DISCONNECTED));
53+
ROOM_LOCK_PREFIX,
54+
roomId,
55+
() ->
56+
roomService.changeConnectedStatus(
57+
roomId, userId, ConnectionState.DISCONNECTED));
5458

5559
taskManager.scheduleDisconnectTask(
56-
userId,
57-
() -> {
58-
lockExecutor.executeWithLock(ROOM_LOCK_PREFIX, roomId,
59-
() -> {
60-
if (ConnectionState.DISCONNECTED.equals(
61-
roomService.getPlayerState(userId, roomId))) {
62-
roomService.disconnectOrExitRoom(roomId, principal);
63-
}
64-
}
65-
);
66-
});
60+
userId,
61+
() -> {
62+
lockExecutor.executeWithLock(
63+
ROOM_LOCK_PREFIX,
64+
roomId,
65+
() -> {
66+
if (ConnectionState.DISCONNECTED.equals(
67+
roomService.getPlayerState(userId, roomId))) {
68+
roomService.disconnectOrExitRoom(roomId, principal);
69+
}
70+
});
71+
});
6772
}
6873
}

backend/src/main/java/io/f1/backend/global/exception/errorcode/CommonErrorCode.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public enum CommonErrorCode implements ErrorCode {
1616
LOCK_ACQUISITION_FAILED("E409003", HttpStatus.CONFLICT, "다른 요청이 작업 중입니다. 잠시 후 다시 시도해주세요."),
1717
LOCK_INTERRUPTED("E500004", HttpStatus.INTERNAL_SERVER_ERROR, "작업 중 락 획득이 중단되었습니다. 다시 시도해주세요.");
1818

19-
2019
private final String code;
2120

2221
private final HttpStatus httpStatus;

backend/src/main/java/io/f1/backend/global/lock/LockExecutor.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44

55
import io.f1.backend.global.exception.CustomException;
66
import io.f1.backend.global.exception.errorcode.CommonErrorCode;
7-
import java.util.concurrent.TimeUnit;
8-
import java.util.function.Supplier;
7+
98
import lombok.RequiredArgsConstructor;
109
import lombok.extern.slf4j.Slf4j;
10+
1111
import org.redisson.api.RLock;
1212
import org.redisson.api.RedissonClient;
1313
import org.springframework.stereotype.Component;
1414

15+
import java.util.concurrent.TimeUnit;
16+
import java.util.function.Supplier;
17+
1518
@Slf4j
1619
@Component
1720
@RequiredArgsConstructor
@@ -36,7 +39,7 @@ public <T> T executeWithLock(String prefix, Object key, Supplier<T> supplier) {
3639
try {
3740
acquired = rlock.tryLock(DEFAULT_WAIT_TIME, DEFAULT_LEASE_TIME, DEFAULT_TIME_UNIT);
3841

39-
if(!acquired) {
42+
if (!acquired) {
4043
log.warn("[DistributedLock] Lock acquisition failed: {}", key);
4144
throw new CustomException(CommonErrorCode.LOCK_ACQUISITION_FAILED);
4245
}
@@ -55,13 +58,15 @@ public <T> T executeWithLock(String prefix, Object key, Supplier<T> supplier) {
5558
}
5659

5760
public void executeWithLock(String prefix, Object key, Runnable runnable) {
58-
executeWithLock(prefix, key, () -> {
59-
runnable.run();
60-
return null;
61-
});
61+
executeWithLock(
62+
prefix,
63+
key,
64+
() -> {
65+
runnable.run();
66+
return null;
67+
});
6268
}
6369

64-
6570
private String formatLockKey(String prefix, Object value) {
6671
return String.format(LOCK_KEY_FORMAT, prefix, value);
6772
}

backend/src/test/java/io/f1/backend/domain/game/app/GameFlowTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static class TestRoomService extends RoomService {
222222
private final Map<Long, Room> rooms = new ConcurrentHashMap<>();
223223

224224
public TestRoomService() {
225-
super(null, null, null, null, null, null,null);
225+
super(null, null, null, null, null, null, null);
226226
}
227227

228228
@Override

0 commit comments

Comments
 (0)