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


##########
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:
   The comment references Jackson's `JsonWriteFeatures#WRITE_NAN_AS_STRINGS`, 
but the PR description (and Jackson API) uses 
`JsonWriteFeature#WRITE_NAN_AS_STRINGS` (singular). Please correct the type 
name to avoid a misleading reference.



##########
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:
   Same as above: `JsonWriteFeatures` in the comment should be 
`JsonWriteFeature` (singular) to match the actual Jackson feature name.



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