You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2019/06/23 05:38:23 UTC

[logging-log4j2] branch master updated: LOG4J2-2622 - StructuredDataId was ignoring maxLength atribute

This is an automated email from the ASF dual-hosted git repository.

rgoers pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


The following commit(s) were added to refs/heads/master by this push:
     new 3c37fd3  LOG4J2-2622 - StructuredDataId was ignoring maxLength atribute
3c37fd3 is described below

commit 3c37fd369517203a96b86cd2516ca67b55b335d2
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Sat Jun 22 22:38:11 2019 -0700

    LOG4J2-2622 - StructuredDataId was ignoring maxLength atribute
---
 .../java/org/apache/logging/log4j/message/StructuredDataId.java   | 8 +++++---
 src/changes/changes.xml                                           | 3 +++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataId.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataId.java
index 232f156..674bd35 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataId.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataId.java
@@ -95,11 +95,13 @@ public class StructuredDataId implements Serializable, StringBuilderFormattable
      * @param optional The list of keys that are optional for this id.
      * @since 2.9
      */
-    public StructuredDataId(final String name, final String[] required, final String[] optional,
-                               final int maxLength) {
+    public StructuredDataId(final String name, final String[] required, final String[] optional, int maxLength) {
         int index = -1;
         if (name != null) {
-            if (maxLength > 0 && name.length() > MAX_LENGTH) {
+            if (maxLength <= 0) {
+                maxLength = MAX_LENGTH;
+            }
+            if (name.length() > maxLength) {
                 throw new IllegalArgumentException(String.format("Length of id %s exceeds maximum of %d characters",
                         name, maxLength));
             }
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 2026829..f80fe1e 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -142,6 +142,9 @@
       </action>
     </release>
     <release version="2.12.0" date="2019-MM-DD" description="GA Release 2.12.0">
+      <action issue="LOG4J2-2622" dev="rgoers" type="fix">
+        StructuredDataId was ignoring maxLength atribute.
+      </action>
       <action issue="LOG4J2-2636" dev="rgoers" type="fix">
         RFC5424Layout was not properly setting default Structured Element id for the MDC
       </action>