From 86c9abc554804f7b72145d627ee2ef4e3ea963f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Fri, 10 May 2024 12:33:01 +0200 Subject: [PATCH] Resolved performance issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The stacktrace analysis is now done just when - it is detected that some handler/formatter uses its results - it is explicitly enabled Signed-off-by: David Matějček --- .../glassfish/main/jul/GlassFishLogger.java | 18 +++++--- .../cfg/GlassFishLogManagerConfiguration.java | 39 +++++++++++++++++- .../jul/cfg/GlassFishLoggingConstants.java | 20 ++++++++- .../jul/formatter/GlassFishLogFormatter.java | 5 ++- .../main/jul/handler/LogRecordBuffer.java | 4 +- .../main/jul/handler/LoggingOutputStream.java | 27 +++++++----- .../main/jul/record/GlassFishLogRecord.java | 26 ++++-------- .../jul/GlassFishLoggerPerformanceTest.java | 41 +++++++++++++++---- .../jul/handler/GlassFishLogHandlerTest.java | 8 ++-- .../jul/handler/LoggingPrintStreamTest.java | 4 +- .../jul/handler/SimpleLogHandlerTest.java | 6 +-- .../main/jul/handler/SyslogHandlerTest.java | 4 +- .../jul/record/GlassFishLogRecordTest.java | 8 ++-- .../main/jul/record/MessageResolverTest.java | 4 +- 14 files changed, 147 insertions(+), 67 deletions(-) diff --git a/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/GlassFishLogger.java b/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/GlassFishLogger.java index 13b5b886da4..1411be20801 100644 --- a/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/GlassFishLogger.java +++ b/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/GlassFishLogger.java @@ -157,7 +157,7 @@ public void log(final Level level, final String msg) { if (!isProcessible(level, status)) { return; } - final LogRecord record = new GlassFishLogRecord(level, msg); + final LogRecord record = new GlassFishLogRecord(level, msg, isClassAndMethodDetectionEnabled()); record.setLoggerName(getName()); record.setResourceBundle(getResourceBundle()); record.setResourceBundleName(getResourceBundleName()); @@ -171,7 +171,7 @@ public void log(final Level level, final Supplier msgSupplier) { if (!isProcessible(level, status)) { return; } - final LogRecord record = new GlassFishLogRecord(level, msgSupplier.get()); + final LogRecord record = new GlassFishLogRecord(level, msgSupplier.get(), isClassAndMethodDetectionEnabled()); record.setLoggerName(getName()); logOrQueue(record, status); } @@ -189,7 +189,7 @@ public void log(final Level level, final String msg, final Object[] params) { if (!isProcessible(level, status)) { return; } - final LogRecord record = new GlassFishLogRecord(level, msg); + final LogRecord record = new GlassFishLogRecord(level, msg, isClassAndMethodDetectionEnabled()); record.setLoggerName(getName()); record.setResourceBundle(getResourceBundle()); record.setResourceBundleName(getResourceBundleName()); @@ -204,7 +204,7 @@ public void log(final Level level, final String msg, final Throwable thrown) { if (!isProcessible(level, status)) { return; } - final LogRecord record = new GlassFishLogRecord(level, msg); + final LogRecord record = new GlassFishLogRecord(level, msg, isClassAndMethodDetectionEnabled()); record.setLoggerName(getName()); record.setResourceBundle(getResourceBundle()); record.setResourceBundleName(getResourceBundleName()); @@ -219,7 +219,7 @@ public void log(final Level level, final Throwable thrown, final Supplier + * If it is set to null, GJULE will not perform such detection. + *

+ * If the property is not set, GJULE makes the decision based on known handlers + * (*.printSource value) - if any handler requires this feature, it is enabled. + * It is disabled otherwise or you can forcibly enable it by setting the value to true or false. + * + * @return true if handlers can use source class and method in formatters. + */ + public boolean isClassAndMethodDetectionEnabled() { + return classAndMethodDetectionEnabled; + } + + /** * Creates clone of this instance. */ @@ -136,6 +158,21 @@ public static GlassFishLogManagerConfiguration parse(final InputStream inputStre } + private static boolean resolveClassAndMethodDetectionEnabled(final LoggingProperties properties) { + String value = properties.getProperty(KEY_CLASS_AND_METHOD_DETECTION_ENABLED); + if (Boolean.TRUE.toString().equalsIgnoreCase(value)) { + return true; + } + if (Boolean.FALSE.toString().equalsIgnoreCase(value)) { + return false; + } + return properties.stringPropertyNames().stream() + .filter(name -> name.endsWith(KEY_FORMATTER_PRINT_SOURCE_SUFFIX)) + .anyMatch(name -> properties.getProperty(name, Boolean.FALSE.toString()) + .equalsIgnoreCase(Boolean.TRUE.toString())); + } + + /** * Configuration entry, pair of a key and a value, both can be null (but it is not very useful). */ diff --git a/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/cfg/GlassFishLoggingConstants.java b/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/cfg/GlassFishLoggingConstants.java index 4feb5fc7d62..d24c32fda5e 100644 --- a/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/cfg/GlassFishLoggingConstants.java +++ b/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/cfg/GlassFishLoggingConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Eclipse Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024 Eclipse Foundation and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -16,6 +16,7 @@ package org.glassfish.main.jul.cfg; +import java.util.logging.LogRecord; /** * Constants used to configure the Java Util Logging. @@ -67,6 +68,23 @@ public class GlassFishLoggingConstants { /** If this key is set to true, GJULE will print really detailed tracing info to the standard output */ public static final String KEY_TRACING_ENABLED = "org.glassfish.main.jul.tracing.enabled"; + /** + * If this key is set to true, GJULE will detect the caller class and method from stacktrace, + * which is quite expensive operation affecting logging throughput. + *

+ * If it is set to null, GJULE will not perform such detection. + *

+ * If the property is not set, GJULE makes the decision based on known handlers + * (*.printSource value) - if any handler requires this feature, it is enabled. + * It is disabled otherwise or you can forcibly enable it by setting the value to true or false. + */ + public static final String KEY_CLASS_AND_METHOD_DETECTION_ENABLED = "org.glassfish.main.jul.classAndMethodDetection.enabled"; + /** + * Enable printing the source class and method of the LogRecord. + * See {@link LogRecord#getSourceClassName()} and {@link LogRecord#getSourceMethodName()} + */ + public static final String KEY_FORMATTER_PRINT_SOURCE_SUFFIX = "printSource"; + /** 1 000 000 */ public static final long BYTES_PER_MEGABYTES = 1_000_000; diff --git a/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/formatter/GlassFishLogFormatter.java b/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/formatter/GlassFishLogFormatter.java index 25680c1e59d..c16cb843e74 100644 --- a/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/formatter/GlassFishLogFormatter.java +++ b/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/formatter/GlassFishLogFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Eclipse Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024 Eclipse Foundation and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -31,6 +31,7 @@ import static java.time.temporal.ChronoField.MINUTE_OF_HOUR; import static java.time.temporal.ChronoField.NANO_OF_SECOND; import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; +import static org.glassfish.main.jul.cfg.GlassFishLoggingConstants.KEY_FORMATTER_PRINT_SOURCE_SUFFIX; import static org.glassfish.main.jul.formatter.GlassFishLogFormatter.GlassFishLogFormatterProperty.PRINT_SEQUENCE_NUMBER; import static org.glassfish.main.jul.formatter.GlassFishLogFormatter.GlassFishLogFormatterProperty.PRINT_SOURCE; import static org.glassfish.main.jul.formatter.GlassFishLogFormatter.GlassFishLogFormatterProperty.TIMESTAMP_FORMAT; @@ -249,7 +250,7 @@ public enum GlassFishLogFormatterProperty implements LogProperty { * Enable printing the source class and method of the LogRecord. * See {@link LogRecord#getSourceClassName()} and {@link LogRecord#getSourceMethodName()} */ - PRINT_SOURCE("printSource"), + PRINT_SOURCE(KEY_FORMATTER_PRINT_SOURCE_SUFFIX), ; private final String propertyName; diff --git a/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/handler/LogRecordBuffer.java b/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/handler/LogRecordBuffer.java index c91c9a25c7c..cd99004238b 100644 --- a/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/handler/LogRecordBuffer.java +++ b/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/handler/LogRecordBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Eclipse Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024 Eclipse Foundation and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -144,7 +144,7 @@ private void addWithTimeout(final GlassFishLogRecord record) { this + ": The buffer was forcibly cleared after " + maxWait + " s timeout for adding another log record." // + " Log records were lost." // + " It might be caused by a recursive deadlock," // - + " you can increase the capacity or the timeout to avoid this.")); + + " you can increase the capacity or the timeout to avoid this.", false)); } diff --git a/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/handler/LoggingOutputStream.java b/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/handler/LoggingOutputStream.java index 6d2815a4f0c..8a28ab22c31 100644 --- a/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/handler/LoggingOutputStream.java +++ b/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/handler/LoggingOutputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Eclipse Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024 Eclipse Foundation and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -24,6 +24,7 @@ import java.util.logging.LogRecord; import java.util.logging.Logger; +import org.glassfish.main.jul.GlassFishLogManager; import org.glassfish.main.jul.record.GlassFishLogRecord; @@ -68,10 +69,10 @@ void addRecord(final Throwable throwable) { if (closed.get()) { return; } - final GlassFishLogRecord logRecord = new GlassFishLogRecord(logRecordLevel, ""); - logRecord.setThrown(throwable); - logRecord.setLoggerName(this.loggerName); - logRecordBuffer.add(logRecord); + final GlassFishLogRecord record = new GlassFishLogRecord(logRecordLevel, "", isSourceDetectionEnabled()); + record.setThrown(throwable); + record.setLoggerName(this.loggerName); + logRecordBuffer.add(record); } @@ -86,14 +87,14 @@ public void flush() throws IOException { if (closed.get()) { return; } - final String logMessage = getMessage(); - if (logMessage.isEmpty() || lineSeparator.equals(logMessage)) { + final String message = getMessage(); + if (message.isEmpty() || lineSeparator.equals(message)) { // avoid empty records return; } - final GlassFishLogRecord logRecord = new GlassFishLogRecord(logRecordLevel, logMessage); - logRecord.setLoggerName(this.loggerName); - logRecordBuffer.add(logRecord); + final GlassFishLogRecord record = new GlassFishLogRecord(logRecordLevel, message, isSourceDetectionEnabled()); + record.setLoggerName(this.loggerName); + logRecordBuffer.add(record); } private synchronized String getMessage() throws IOException { @@ -104,6 +105,12 @@ private synchronized String getMessage() throws IOException { } + private boolean isSourceDetectionEnabled() { + final GlassFishLogManager manager = GlassFishLogManager.getLogManager(); + return manager == null ? false : manager.getConfiguration().isClassAndMethodDetectionEnabled(); + } + + /** * Shutdown the internal logging pump. */ diff --git a/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/record/GlassFishLogRecord.java b/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/record/GlassFishLogRecord.java index a7d2945bdfb..dedd82faeb1 100644 --- a/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/record/GlassFishLogRecord.java +++ b/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/record/GlassFishLogRecord.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Eclipse Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024 Eclipse Foundation and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -42,16 +42,6 @@ public class GlassFishLogRecord extends LogRecord { private final String threadName; private String messageKey; - /** - * Creates new record. Source class and method will be autodetected. - * - * @param level - * @param message - */ - public GlassFishLogRecord(final Level level, final String message) { - this(new LogRecord(level, message), true); - } - /** * Creates new record. Source class and method will be autodetected now or set after this @@ -298,23 +288,21 @@ public String toString() { } - private boolean detectClassAndMethod(final LogRecord wrappedRecord) { - final StackTraceElement[] stack = new Throwable().getStackTrace(); - boolean found = false; + private void detectClassAndMethod(final LogRecord wrappedRecord) { + final StackTraceElement[] stack = Thread.currentThread().getStackTrace(); + boolean ignoredClass = false; for (final StackTraceElement element : stack) { final String className = element.getClassName(); - if (!found) { - found = isIgnoredStackTraceElement(className); + if (!ignoredClass) { + ignoredClass = isIgnoredStackTraceElement(className); continue; } if (!isIgnoredStackTraceElement(className)) { wrappedRecord.setSourceClassName(className); wrappedRecord.setSourceMethodName(element.getMethodName()); - return true; + return; } } - // don't try it again. - return true; } diff --git a/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/GlassFishLoggerPerformanceTest.java b/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/GlassFishLoggerPerformanceTest.java index 4b6b57e0814..a6c107f5b56 100644 --- a/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/GlassFishLoggerPerformanceTest.java +++ b/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/GlassFishLoggerPerformanceTest.java @@ -47,36 +47,37 @@ public class GlassFishLoggerPerformanceTest { private static final Logger LOG = System.getLogger(GlassFishLoggerPerformanceTest.class.getName()); private static final int COUNT_OF_RECORDS = 100_000; private static final Random RND = new Random(System.currentTimeMillis()); + private static final java.util.logging.Logger JUL_LOGGER = java.util.logging.Logger.getLogger(LOG.getName()); private static LogCollectorHandler collector; private long start; @BeforeAll static void collect() { - java.util.logging.Logger logger = java.util.logging.Logger.getLogger(LOG.getName()); - logger.setUseParentHandlers(false); - logger.setLevel(Level.INFO); - collector = new LogCollectorHandler(logger, COUNT_OF_RECORDS, 10); + JUL_LOGGER.setUseParentHandlers(false); + JUL_LOGGER.setLevel(Level.INFO); + collector = new LogCollectorHandler(JUL_LOGGER, COUNT_OF_RECORDS, 10); } @BeforeEach - void saveTime(TestInfo info) { - System.out.println("Starting test: " + info.getTestMethod().get().getName()); + void saveTime() { start = System.currentTimeMillis(); } @AfterEach - void resetCollector(TestInfo info) { + void logAndReset(TestInfo info) { System.out .println(info.getTestMethod().get().getName() + " time: " + (System.currentTimeMillis() - start) + " ms"); - List records = collector.getAll(); - assertThat(records, hasSize(COUNT_OF_RECORDS)); + final List records = collector.getAll(); + final int expectedRecords = LOG.isLoggable(INFO) ? COUNT_OF_RECORDS : 0; + assertThat(records, hasSize(expectedRecords)); for (LogRecord record : records) { assertThat("message", record.getMessage(), startsWith("Ororok orebuh, random: ")); } collector.reset(); + JUL_LOGGER.setLevel(Level.INFO); } @@ -116,6 +117,17 @@ void testSupplierWithConcat() throws Exception { } + @RepeatedTest(value = 5) + @Timeout(value = 50, unit = TimeUnit.MILLISECONDS) + void testSupplierWithConcatWithLevelOff() throws Exception { + JUL_LOGGER.setLevel(Level.OFF); + int i = 0; + while (i++ < COUNT_OF_RECORDS) { + LOG.log(INFO, () -> "Ororok orebuh, random: " + RND.nextInt()); + } + } + + @RepeatedTest(value = 5) void testMessageFormatter() throws Exception { int i = 0; @@ -123,4 +135,15 @@ void testMessageFormatter() throws Exception { LOG.log(INFO, "Ororok orebuh, random: {0}", RND.nextInt()); } } + + + @RepeatedTest(value = 5) + @Timeout(value = 50, unit = TimeUnit.MILLISECONDS) + void testMessageFormatterWithLevelOff() throws Exception { + JUL_LOGGER.setLevel(Level.OFF); + int i = 0; + while (i++ < COUNT_OF_RECORDS) { + LOG.log(INFO, "Ororok orebuh, random: {0}", RND.nextInt()); + } + } } diff --git a/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/handler/GlassFishLogHandlerTest.java b/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/handler/GlassFishLogHandlerTest.java index 35fcfa6c56e..c6b415aef60 100644 --- a/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/handler/GlassFishLogHandlerTest.java +++ b/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/handler/GlassFishLogHandlerTest.java @@ -133,7 +133,7 @@ public void enableStandardStreamsLoggers(TestInfo testInfo) throws Exception { @Order(30) public void roll() throws Exception { assertTrue(handler.isReady(), "handler.ready"); - handler.publish(new GlassFishLogRecord(Level.SEVERE, "File one, record one")); + handler.publish(new GlassFishLogRecord(Level.SEVERE, "File one, record one", false)); // pump is now to play Thread.sleep(MILLIS_FOR_PUMP); assertAll( @@ -155,18 +155,18 @@ public void roll() throws Exception { () -> assertTrue(handler.getConfiguration().getLogFile().exists(), "file exists"), () -> assertThat("file content", Files.readAllLines(handler.getConfiguration().getLogFile().toPath()), contains( - stringContainsInOrder("INFO", "main", "roll Archived file:", "if null, action failed.") + stringContainsInOrder("INFO", "main", "Archived file:", "if null, action failed.") ) ) ); - handler.publish(new GlassFishLogRecord(Level.SEVERE, "File two, line two")); + handler.publish(new GlassFishLogRecord(Level.SEVERE, "File two, line two", false)); Thread.sleep(MILLIS_FOR_PUMP); assertAll( () -> assertTrue(handler.isReady(), "handler.ready"), () -> assertTrue(handler.getConfiguration().getLogFile().exists(), "file exists"), () -> assertThat("file content", Files.readAllLines(handler.getConfiguration().getLogFile().toPath()), contains( - stringContainsInOrder("INFO", "main", "roll Archived file:", "if null, action failed."), + stringContainsInOrder("INFO", "main", "Archived file:", "if null, action failed."), stringContainsInOrder("SEVERE", "main", "File two, line two") ) ) diff --git a/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/handler/LoggingPrintStreamTest.java b/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/handler/LoggingPrintStreamTest.java index c6766a1c276..7fb3b201ebb 100644 --- a/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/handler/LoggingPrintStreamTest.java +++ b/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/handler/LoggingPrintStreamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Eclipse Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024 Eclipse Foundation and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -98,7 +98,7 @@ public void testPrintStacktrace() throws Exception { () -> assertEquals(1L, record.getThreadID()), () -> assertEquals(Thread.currentThread().getName(), record.getThreadName()), () -> assertSame(exception, record.getThrown()), - () -> assertEquals("testPrintStacktrace", record.getSourceMethodName()) + () -> assertNull(record.getSourceMethodName()) ); } diff --git a/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/handler/SimpleLogHandlerTest.java b/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/handler/SimpleLogHandlerTest.java index ef5e336b56a..3999a77f86b 100644 --- a/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/handler/SimpleLogHandlerTest.java +++ b/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/handler/SimpleLogHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Eclipse Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024 Eclipse Foundation and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -65,7 +65,7 @@ public void resetOutput() throws Exception { @Test void standardMessage() throws Exception { final SimpleLogHandler handler = new SimpleLogHandler(logCollector); - final GlassFishLogRecord record = new GlassFishLogRecord(Level.INFO, "This should log."); + final GlassFishLogRecord record = new GlassFishLogRecord(Level.INFO, "This should log.", false); record.setSourceClassName("FakeClass"); record.setSourceMethodName("fakeMethod"); handler.publish(record); @@ -83,7 +83,7 @@ void standardMessage() throws Exception { @Test void exception() throws Exception { final SimpleLogHandler handler = new SimpleLogHandler(logCollector); - final GlassFishLogRecord record = new GlassFishLogRecord(Level.SEVERE, "This should log."); + final GlassFishLogRecord record = new GlassFishLogRecord(Level.SEVERE, "This should log.", false); record.setSourceClassName("FakeClass"); record.setSourceMethodName("fakeMethod"); record.setThrown(new IllegalStateException("Something broke.")); diff --git a/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/handler/SyslogHandlerTest.java b/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/handler/SyslogHandlerTest.java index 3fbd8e75549..b99b4f03998 100644 --- a/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/handler/SyslogHandlerTest.java +++ b/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/handler/SyslogHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Eclipse Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024 Eclipse Foundation and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -57,7 +57,7 @@ public void test() throws Exception { manager.reconfigure(new GlassFishLogManagerConfiguration(properties)); SyslogHandler handler = new SyslogHandler(); - handler.publish(new GlassFishLogRecord(Level.SEVERE, "This is a test.")); + handler.publish(new GlassFishLogRecord(Level.SEVERE, "This is a test.", false)); Thread.sleep(100L); } diff --git a/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/record/GlassFishLogRecordTest.java b/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/record/GlassFishLogRecordTest.java index 1bc60ec3afc..9ac43f9642a 100644 --- a/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/record/GlassFishLogRecordTest.java +++ b/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/record/GlassFishLogRecordTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Eclipse Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024 Eclipse Foundation and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -45,7 +45,7 @@ public class GlassFishLogRecordTest { */ @Test void nullParameters() throws Exception { - final GlassFishLogRecord record = new GlassFishLogRecord(Level.ALL, null); + final GlassFishLogRecord record = new GlassFishLogRecord(Level.ALL, null, false); record.setLevel(Level.INFO); record.setMessage(null); record.setLoggerName(null); @@ -63,7 +63,7 @@ void nullParameters() throws Exception { @Test void emptyParameters() throws Exception { - final GlassFishLogRecord record = new GlassFishLogRecord(Level.CONFIG, ""); + final GlassFishLogRecord record = new GlassFishLogRecord(Level.CONFIG, "", false); record.setMessage(""); record.setLoggerName(""); record.setParameters(new Object[] {}); @@ -75,7 +75,7 @@ void emptyParameters() throws Exception { @Test void serialization() throws Exception { - final GlassFishLogRecord record = new GlassFishLogRecord(Level.CONFIG, "message"); + final GlassFishLogRecord record = new GlassFishLogRecord(Level.CONFIG, "message", false); record.setLevel(Level.FINEST); record.setMessage("message2"); record.setLoggerName("loggerNameX"); diff --git a/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/record/MessageResolverTest.java b/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/record/MessageResolverTest.java index 994c6a0f9bc..bb6fa59ee43 100644 --- a/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/record/MessageResolverTest.java +++ b/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/record/MessageResolverTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Eclipse Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024 Eclipse Foundation and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -34,7 +34,7 @@ public class MessageResolverTest { @Test public void testResolve() { final GlassFishLogRecord originalRecord = new GlassFishLogRecord(Level.INFO, - "This number {0,number,#} is greater than this one {1,number,#}"); + "This number {0,number,#} is greater than this one {1,number,#}", false); originalRecord.setParameters(new Object[] {50L, 33L}); final GlassFishLogRecord record = resolver.resolve(originalRecord); assertAll(() -> assertNull(record.getMessageKey()),