Skip to content

Commit ec10ef0

Browse files
committed
Revert "remove superfluent counter and fix log message (apache#6313)"
This reverts commit a9bbcf8.
1 parent 1964b7f commit ec10ef0

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

server/src/main/java/com/cloud/api/ApiSessionListener.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,17 @@ public class ApiSessionListener implements HttpSessionListener, ServletRequestLi
3333
public static final Logger LOGGER = Logger.getLogger(ApiSessionListener.class.getName());
3434
private static final String ATTRIBUTE_NAME = "SessionCounter";
3535
private static Map<HttpSession, Object> sessions = new ConcurrentHashMap<>();
36+
private static long sessionCount;
37+
38+
public ApiSessionListener() {
39+
sessionCount = 0;
40+
}
3641

3742
/**
3843
* @return the internal adminstered session count
3944
*/
4045
public static long getSessionCount() {
41-
return sessions.size();
46+
return sessionCount;
4247
}
4348

4449
/**
@@ -52,15 +57,17 @@ public void sessionCreated(HttpSessionEvent event) {
5257
synchronized (this) {
5358
HttpSession session = event.getSession();
5459
sessions.put(session, event.getSource());
60+
sessionCount++;
5561
}
56-
LOGGER.debug("Sessions count: " + getSessionCount());
62+
LOGGER.debug("Sessions count: " + sessions);
5763
}
5864
public void sessionDestroyed(HttpSessionEvent event) {
5965
LOGGER.debug("Session destroyed by Id : " + event.getSession().getId() + " , session: " + event.getSession().toString() + " , source: " + event.getSource().toString() + " , event: " + event.toString());
6066
synchronized (this) {
67+
sessionCount--;
6168
sessions.remove(event.getSession());
6269
}
63-
LOGGER.debug("Sessions count: " + getSessionCount());
70+
LOGGER.debug("Sessions count: " + sessions);
6471
}
6572

6673
@Override

0 commit comments

Comments
 (0)