lauredogit commented on PR #2249: URL: https://github.com/apache/logging-log4j2/pull/2249#issuecomment-1960973519
Hi, This changes caused an issue when running on Java 8 and having configured a DateFormat. It will cause a StackOverflowError such as: `Caused by: java.lang.StackOverflowError at org.apache.logging.log4j.message.ParameterFormatter.analyzePattern(ParameterFormatter.java:93) at org.apache.logging.log4j.message.ParameterizedMessage.<init>(ParameterizedMessage.java:142) at org.apache.logging.log4j.message.ParameterizedMessage.<init>(ParameterizedMessage.java:176) at org.apache.logging.log4j.message.ParameterizedNoReferenceMessageFactory.newMessage(ParameterizedNoReferenceMessageFactory.java:105) at org.apache.logging.log4j.message.AbstractMessageFactory.newMessage(AbstractMessageFactory.java:103) at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2686) at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:2460) at org.apache.logging.log4j.spi.AbstractLogger.warn(AbstractLogger.java:3674) at org.apache.logging.log4j.spi.AbstractLogger.handleLogMessageException(AbstractLogger.java:2927) at org.apache.logging.log4j.spi.AbstractLogger.tryLogMessage(AbstractLogger.java:2909) at org.apache.logging.log4j.spi.AbstractLogger.logMessageTrackRecursion(AbstractLogger.java:2859) at org.apache.logging.log4j.spi.AbstractLogger.logMessageSafely(AbstractLogger.java:2841) at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2687) at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:2460) at org.apache.logging.log4j.spi.AbstractLogger.warn(AbstractLogger.java:3674) at org.apache.logging.log4j.spi.AbstractLogger.handleLogMessageException(AbstractLogger.java:2927)` which is caused by `java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: YearOfEra at java.time.Instant.getLong(Instant.java:603) at java.time.format.DateTimePrintContext.getValue(DateTimePrintContext.java:298) at java.time.format.DateTimeFormatterBuilder$NumberPrinterParser.format(DateTimeFormatterBuilder.java:2551) at java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.format(DateTimeFormatterBuilder.java:2190) at java.time.format.DateTimeFormatter.formatTo(DateTimeFormatter.java:1746) at java.time.format.DateTimeFormatter.format(DateTimeFormatter.java:1720) at org.apache.logging.log4j.status.StatusData.getFormattedStatus(StatusData.java:170) at org.apache.logging.log4j.status.StatusConsoleListener.log(StatusConsoleListener.java:138) at org.apache.logging.log4j.status.StatusLogger.notifyListener(StatusLogger.java:555) at org.apache.logging.log4j.status.StatusLogger.notifyListeners(StatusLogger.java:549) at org.apache.logging.log4j.status.StatusLogger.logMessage(StatusLogger.java:526) at org.apache.logging.log4j.spi.AbstractLogger.log(AbstractLogger.java:2812) at org.apache.logging.log4j.spi.AbstractLogger.tryLogMessage(AbstractLogger.java:2906) at org.apache.logging.log4j.spi.AbstractLogger.logMessageTrackRecursion(AbstractLogger.java:2859) at org.apache.logging.log4j.spi.AbstractLogger.logMessageSafely(AbstractLogger.java:2841) at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2620) at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:2567) at org.apache.logging.log4j.spi.AbstractLogger.warn(AbstractLogger.java:3469)` because in org.apache.logging.log4j.status.StatusLogger.Config#readInstantFormatter, the code is merely ` private static DateTimeFormatter readInstantFormatter(final Properties fileProvidedProperties) { final String format = readProperty(fileProvidedProperties, STATUS_DATE_FORMAT); return format != null ? DateTimeFormatter.ofPattern(format) : null; } ` with only **DateTimeFormatter.ofPattern(format)** This works on Java 11, but on Java 8, it breaks as in https://stackoverflow.com/questions/25229124/unsupportedtemporaltypeexception-when-formatting-instant-to-string A very simple fix is to use instead ` private static DateTimeFormatter readInstantFormatter(final Properties fileProvidedProperties) { final String format = readProperty(fileProvidedProperties, STATUS_DATE_FORMAT); return format != null ? DateTimeFormatter.ofPattern(format).withZone(ZoneId.systemDefault()) : null; }` -- 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: notifications-unsubscr...@logging.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org