Skip to content

Commit 093d086

Browse files
committed
polishing mvn format with mvn spottless apply
1 parent 351cf60 commit 093d086

File tree

6 files changed

+141
-174
lines changed

6 files changed

+141
-174
lines changed

microservices-log-aggregation/src/main/java/com/iluwatar/logaggregation/LogAggregator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* THE SOFTWARE.
2424
*/
2525
package com.iluwatar.logaggregation;
26+
2627
import java.util.ArrayList;
2728
import java.util.List;
2829
import java.util.concurrent.BlockingQueue;
@@ -33,6 +34,7 @@
3334
import java.util.concurrent.TimeUnit;
3435
import java.util.concurrent.atomic.AtomicInteger;
3536
import lombok.extern.slf4j.Slf4j;
37+
3638
/**
3739
* Responsible for collecting and buffering logs from different services. Once the logs reach a
3840
* certain threshold or after a certain time interval, they are flushed to the central log store.
@@ -206,8 +208,7 @@ private void startPeriodicFlusher() {
206208
FLUSH_INTERVAL_SECONDS, // Period
207209
TimeUnit.SECONDS);
208210

209-
LOGGER.info(
210-
"Periodic log flusher started with interval of {} seconds", FLUSH_INTERVAL_SECONDS);
211+
LOGGER.info("Periodic log flusher started with interval of {} seconds", FLUSH_INTERVAL_SECONDS);
211212
}
212213

213214
/**

microservices-log-aggregation/src/test/java/com/iluwatar/logaggregation/LogAggregatorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,4 @@ private void verifyNoInteractionsWithCentralLogStore() {
195195
private void verifyCentralLogStoreInvokedTimes(int times) {
196196
verify(centralLogStore, times(times)).storeLog(any());
197197
}
198-
}
198+
}

server-session/src/main/java/com/iluwatar/sessionserver/App.java

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,16 @@
2424
*/
2525
package com.iluwatar.sessionserver;
2626

27-
28-
import java.util.HashMap;
2927
import com.sun.net.httpserver.HttpServer;
3028
import java.io.IOException;
3129
import java.net.InetSocketAddress;
32-
import java.util.Iterator;
3330
import java.time.Instant;
34-
import java.util.concurrent.ConcurrentHashMap;
31+
import java.util.HashMap;
32+
import java.util.Map;
33+
import java.util.concurrent.CountDownLatch;
3534
import java.util.concurrent.Executors;
3635
import java.util.concurrent.ScheduledExecutorService;
3736
import java.util.concurrent.TimeUnit;
38-
import java.util.concurrent.CountDownLatch;
39-
import java.util.Map;
4037
import lombok.extern.slf4j.Slf4j;
4138

4239
/**
@@ -68,7 +65,6 @@ public class App {
6865
private static volatile boolean running = true;
6966
private static final CountDownLatch shutdownLatch = new CountDownLatch(1);
7067

71-
7268
/**
7369
* Main entry point.
7470
*
@@ -106,33 +102,36 @@ private static void sessionExpirationTask() {
106102
try {
107103
LOGGER.info("Session expiration checker started...");
108104
Instant currentTime = Instant.now();
109-
105+
110106
// Use removeIf for efficient removal without explicit synchronization
111107
// ConcurrentHashMap handles thread safety internally
112-
sessionCreationTimes.entrySet().removeIf(entry -> {
113-
if (entry.getValue().plusMillis(SESSION_EXPIRATION_TIME).isBefore(currentTime)) {
114-
sessions.remove(entry.getKey());
115-
LOGGER.debug("Expired session: {}", entry.getKey());
116-
return true;
117-
}
118-
return false;
119-
});
120-
108+
sessionCreationTimes
109+
.entrySet()
110+
.removeIf(
111+
entry -> {
112+
if (entry.getValue().plusMillis(SESSION_EXPIRATION_TIME).isBefore(currentTime)) {
113+
sessions.remove(entry.getKey());
114+
LOGGER.debug("Expired session: {}", entry.getKey());
115+
return true;
116+
}
117+
return false;
118+
});
119+
121120
LOGGER.info("Session expiration checker finished! Active sessions: {}", sessions.size());
122121
} catch (Exception e) {
123122
LOGGER.error("An error occurred during session expiration check: ", e);
124123
}
125124
}
126125

127-
/**
128-
* Gracefully shuts down the session expiration scheduler.
129-
* This method is called by the shutdown hook.
126+
/**
127+
* Gracefully shuts down the session expiration scheduler. This method is called by the shutdown
128+
* hook.
130129
*/
131130
private static void shutdown() {
132131
LOGGER.info("Shutting down session expiration scheduler...");
133132
running = false;
134133
scheduler.shutdown();
135-
134+
136135
try {
137136
if (!scheduler.awaitTermination(5, TimeUnit.SECONDS)) {
138137
LOGGER.warn("Scheduler did not terminate gracefully, forcing shutdown");
@@ -143,7 +142,7 @@ private static void shutdown() {
143142
scheduler.shutdownNow();
144143
Thread.currentThread().interrupt();
145144
}
146-
145+
147146
shutdownLatch.countDown();
148147
LOGGER.info("Session expiration scheduler shut down complete");
149148
}

server-session/src/test/java/com/iluwatar/sessionserver/LoginHandlerTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
*/
2525
package com.iluwatar.logaggregation;
2626

27-
import static org.mockito.ArgumentMatchers.any;
28-
import static org.mockito.Mockito.times;
29-
import static org.mockito.Mockito.verify;
30-
31-
import java.time.LocalDateTime;
3227
import org.junit.jupiter.api.BeforeEach;
3328
import org.junit.jupiter.api.Test;
3429
import org.junit.jupiter.api.extension.ExtendWith;
@@ -44,6 +39,7 @@ public class LoginHandlerTest {
4439
private Map<String, Instant> sessionCreationTimes;
4540

4641
@Mock private HttpExchange exchange;
42+
4743
/** Setup tests. */
4844
@BeforeEach
4945
public void setUp() {

0 commit comments

Comments
 (0)