ppkarwasz commented on code in PR #4080:
URL: https://github.com/apache/logging-log4j2/pull/4080#discussion_r2984496707


##########
log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/JsonWriter.java:
##########
@@ -722,11 +722,21 @@ public void writeNumber(final BigInteger number) {
     }
 
     public void writeNumber(final float number) {
-        stringBuilder.append(number);
+        // Follows the same logic as Jackson's 
JsonWriteFeatures#WRITE_NAN_AS_STRINGS feature.
+        if (!Float.isFinite(number)) {
+            writeString(Float.toString(number));
+        } else {
+            stringBuilder.append(number);
+        }
     }
 
     public void writeNumber(final double number) {
-        stringBuilder.append(number);
+        // Follows the same logic as Jackson's 
JsonWriteFeatures#WRITE_NAN_AS_STRINGS feature.
+        if (!Double.isFinite(number)) {

Review Comment:
   Fixed in 
https://github.com/apache/logging-log4j2/pull/4080/commits/ac589bf29dddac5b7823855f973c4811532085ac



##########
log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/JsonWriter.java:
##########
@@ -722,11 +722,21 @@ public void writeNumber(final BigInteger number) {
     }
 
     public void writeNumber(final float number) {
-        stringBuilder.append(number);
+        // Follows the same logic as Jackson's 
JsonWriteFeatures#WRITE_NAN_AS_STRINGS feature.
+        if (!Float.isFinite(number)) {

Review Comment:
   Fixed in 
https://github.com/apache/logging-log4j2/pull/4080/commits/ac589bf29dddac5b7823855f973c4811532085ac



-- 
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