Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-2622

maxLength for StructuredDataId and StructuredDataMessage always maximum 32

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.11.2
    • Fix Version/s: 2.12.0
    • Component/s: API
    • Labels:
      None

      Description

      Try to assign UUID into the StructuredDataMessage, but failed with :

      Exception in thread "main" java.lang.IllegalArgumentException: Length of id dd570301-85b6-11e9-a708-983b8f59247d exceeds maximum of 37 characters
       at org.apache.logging.log4j.message.StructuredDataId.<init>(StructuredDataId.java:103)
      

      Found the bug in the code
      https://github.com/apache/logging-log4j2/blob/master/log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataId.java

          public StructuredDataId(final String name, final String[] required, final String[] optional,
                                     final int maxLength) {
              int index = -1;
              if (name != null) {
                  if (maxLength > 0 && name.length() > MAX_LENGTH) {
                      throw new IllegalArgumentException(String.format("Length of id %s exceeds maximum of %d characters",
                              name, maxLength));
                  }
                  index = name.indexOf(AT_SIGN);
              }
      

      at line 102 , should be
      name.length() > maxLength that bring in but the the MAX_LENGTH

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              yijackyau yijack yau
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: