Skip to content

Commit 0623ca8

Browse files
author
Vladimir Kotal
authored
add log entry and throw exception when message limit is exceeded (#3126)
1 parent ba286a9 commit 0623ca8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/web/messages/MessagesContainer.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import com.fasterxml.jackson.databind.SerializerProvider;
2929
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
3030
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
31+
import org.opengrok.indexer.logger.LoggerFactory;
32+
3133
import javax.validation.constraints.NotBlank;
3234

3335
import java.io.IOException;
@@ -45,10 +47,14 @@
4547
import java.util.TimerTask;
4648
import java.util.TreeSet;
4749
import java.util.function.Predicate;
50+
import java.util.logging.Level;
51+
import java.util.logging.Logger;
4852
import java.util.stream.Collectors;
4953

5054
public class MessagesContainer {
5155

56+
private static final Logger LOGGER = LoggerFactory.getLogger(MessagesContainer.class);
57+
5258
public static final String MESSAGES_MAIN_PAGE_TAG = "main";
5359

5460
private static final int DEFAULT_MESSAGE_LIMIT = 100;
@@ -121,7 +127,9 @@ public void addMessage(final Message m) {
121127
}
122128

123129
if (isMessageLimitExceeded()) {
124-
return;
130+
LOGGER.log(Level.WARNING, "cannot add message to the system, " +
131+
"exceeded Configuration messageLimit of {0}", messageLimit);
132+
throw new IllegalStateException("Cannot add message - message limit exceeded");
125133
}
126134

127135
if (expirationTimer == null) {

0 commit comments

Comments
 (0)