Skip to content

Commit 2109002

Browse files
committed
SonarQube fix try 1
1 parent 27325f2 commit 2109002

File tree

3 files changed

+9
-7
lines changed
  • queue-based-load-leveling/src/main/java/com/iluwatar/queue/load/leveling
  • server-session/src/main/java/com/iluwatar/sessionserver
  • twin/src/main/java/com/iluwatar/twin

3 files changed

+9
-7
lines changed

queue-based-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/MessageQueue.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
public class MessageQueue {
3737

3838
private final BlockingQueue<Message> blkQueue;
39-
public final Object serviceExecutorWait = new Object();
39+
public Object serviceExecutorWait =new Object();
4040

4141
// Default constructor when called creates Blocking Queue object.
4242
public MessageQueue() {
@@ -51,7 +51,9 @@ public void submitMsg(Message msg) {
5151
try {
5252
if (null != msg) {
5353
blkQueue.add(msg);
54-
serviceExecutorWait.notify();
54+
synchronized (serviceExecutorWait) {
55+
serviceExecutorWait.notifyAll();
56+
}
5557
}
5658
} catch (Exception e) {
5759
LOGGER.error(e.getMessage());

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public class App {
5656

5757
// Map to store session data (simulated using a HashMap)
5858

59-
private static Map<String, Integer> sessions = new HashMap<String, Integer>();
60-
private static Map<String, Instant> sessionCreationTimes = new HashMap<String, Instant>();
59+
private static Map<String, Integer> sessions = new HashMap<>();
60+
private static Map<String, Instant> sessionCreationTimes = new HashMap<>();
6161
private static final long SESSION_EXPIRATION_TIME = 10000;
6262
private static final Object sessionExpirationWait = new Object(); // used to make expiration task wait or work based on event (login request sent or not)
6363

@@ -125,7 +125,7 @@ private static void sessionExpirationTask() {
125125
*/
126126
public static void expirationTaskWake() {
127127
synchronized (sessionExpirationWait) {
128-
sessionExpirationWait.notify();
128+
sessionExpirationWait.notifyAll();
129129
}
130130
}
131131

twin/src/main/java/com/iluwatar/twin/BallThread.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void resumeMe() {
8686
LOGGER.info("Begin to resume BallThread");
8787

8888
synchronized (lock) {
89-
lock.notify();
89+
lock.notifyAll();
9090
}
9191
}
9292

@@ -97,7 +97,7 @@ public void stopMe() {
9797
this.isRunning = false;
9898
this.isSuspended = true;
9999
synchronized (lock) {
100-
lock.notify();
100+
lock.notifyAll();
101101
}
102102
}
103103
}

0 commit comments

Comments
 (0)