EgorBaranovEnjoysTyping commented on code in PR #13262:
URL: https://github.com/apache/ignite/pull/13262#discussion_r3481626185


##########
modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/SBLengthLimit.java:
##########
@@ -35,50 +35,44 @@ class SBLengthLimit {
     /** Length of head part of message. */
     private static final int HEAD_LEN = MAX_TO_STR_LEN - TAIL_LEN;
 
-    /** */
-    private int len;
-
-    /**
-     * @return Current length.
-     */
-    int length() {
-        return len;
-    }
-
-    /**
-     *
-     */
-    void reset() {
-        len = 0;
-    }
-
     /**
      * @param sb String builder.
      * @param writtenLen Written length.
      */
     void onWrite(SBLimitedLength sb, int writtenLen) {
-        len += writtenLen;
-
         if (overflowed(sb) && (sb.getTail() == null || sb.getTail().length() 
== 0)) {
-            CircularStringBuilder tail = getTail();
-
-            int newSbLen = Math.min(sb.length(), HEAD_LEN + 1);
+            CircularStringBuilder tail = createTail();
+            int newSbLen = Math.min(sb.length(), getHeadLengthLimit());
             tail.append(sb.impl().substring(newSbLen));
-
             sb.setTail(tail);
-            sb.setLength(newSbLen);
+            sb.impl().setLength(newSbLen);
         }
     }
 
-    /** */
-    CircularStringBuilder getTail() {
-        return new CircularStringBuilder(TAIL_LEN);
+    /** Creates empty tail
+     * @return empty tail */
+    CircularStringBuilder createTail() {
+        return new CircularStringBuilder(getTailLengthLimit());
     }
 
     /**
-     * @return {@code True} if reached limit.
+     * @return {@code True} if this string builder exceeds limit, false 
otherwise
      */
     boolean overflowed(SBLimitedLength sb) {
-        return sb.impl().length() > HEAD_LEN;
+        return sb.length() >= getHeadLengthLimit();
+    }

Review Comment:
   It looks safe



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to