vy commented on code in PR #2515:
URL: https://github.com/apache/logging-log4j2/pull/2515#discussion_r1579481610


##########
log4j-api/src/main/java/org/apache/logging/log4j/status/StatusData.java:
##########
@@ -167,9 +167,9 @@ public Throwable getThrowable() {
     @SuppressWarnings("DefaultCharset")
     public String getFormattedStatus() {
         final StringBuilder sb = new StringBuilder();
-        final String formattedInstant =
-                instantFormatter != null ? instantFormatter.format(instant) : 
instant.toString();
-        sb.append(formattedInstant);
+        // DateTimeFormatter.ISO_INSTANT is the default used in 
instant.toString()
+        DateTimeFormatter formatterToUse = instantFormatter != null ? 
instantFormatter : DateTimeFormatter.ISO_INSTANT;
+        formatterToUse.formatTo(instant, sb);

Review Comment:
   @michaelbraun, could you instead implement this as follows, please?
   1. Remove the `@Nullable` annotation from the `instantFormatter` field
   2. In the canonical ctor (i.e., the package-private one) set 
`instantFormatter` to `DateTimeFormatter.ISO_INSTANT` (with the sufficient 
comment you had earlier) if the one provided in the arguments is null
   3. Use `instantFormatter.formatTo(instant, sb)` in `getFormattedStatus()`



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