Skip to content

Commit

Permalink
adding number formatting for the alert that incoming message is too long
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmipt committed Jun 14, 2024
1 parent fca8b18 commit 23ba58b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/studio/kdb/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

import javax.swing.*;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -31,6 +33,8 @@ public class Session implements ConnectionStateListener, KAuthentication {

private final static Map<Server, Session> sessions = new HashMap<>();

private final static NumberFormat NUMBER_FORMAT = new DecimalFormat("#,###");

public static Session newSession(EditorTab editor) {
Server server = editor.getServer();
Session session;
Expand Down Expand Up @@ -67,7 +71,7 @@ public void checkIncomingLimit(long msgLength) throws IOException {
KdbMessageLimitAction action = Config.getInstance().getEnum(Config.KDB_MESSAGE_SIZE_LIMIT_ACTION);
long limit = 1_000_000L * Config.getInstance().getInt(Config.KDB_MESSAGE_SIZE_LIMIT_MB);
if (msgLength < limit) return;
final String msg = "Incoming message size " + msgLength + " breached the limit of " + limit + ".";
final String msg = "Incoming message size " + NUMBER_FORMAT.format(msgLength) + " breached the limit of " + NUMBER_FORMAT.format(limit) + ".";
if (action == KdbMessageLimitAction.BLOCK) {
throw new IOException(msg);
}
Expand Down

0 comments on commit 23ba58b

Please sign in to comment.