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

maxLength for StructuredDataId and StructuredDataMessage always maximum 32

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.11.2
    • 2.12.0
    • API
    • 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

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment