-
Bug
-
Resolution: Unresolved
-
P4
-
7, 8
-
Fix Understood
While converting some GlassFish code to use localization I ran into an issue with the java.util.logging API.
The use case is early startup log messages are queued in a buffer and then later while the log file is initialized they are written to disk.
See the following snippet of code.
LogRecord lr = new LogRecord(Level.INFO, LogFacade.GF_VERSION_INFO);
lr.setParameters(new Object[]{ Version.getFullVersion()});
lr.setResourceBundle(ResourceBundle.getBundle(LogFacade.LOGGING_RB_NAME));
lr.setThreadID((int) Thread.currentThread().getId());
lr.setLoggerName(LogFacade.LOGGING_LOGGER_NAME);
EarlyLogHandler.earlyMessages.add(lr);
The issue is that earlier I was doing lr.setResourceBundleName(LogFacade.LOGGING_RB_NAME);
This resulted in the early messages appearing in the log file with just keys and without localization.
This was not working because the setResourceBundleName setter does not initialize the actual resource bundle used during logging but just initializes a String value.
So the resourceBundleName and the resourceBundle fields in the LogRecord class can go out of sync.
This is problematic from an API standpoint.
The use case is early startup log messages are queued in a buffer and then later while the log file is initialized they are written to disk.
See the following snippet of code.
LogRecord lr = new LogRecord(Level.INFO, LogFacade.GF_VERSION_INFO);
lr.setParameters(new Object[]{ Version.getFullVersion()});
lr.setResourceBundle(ResourceBundle.getBundle(LogFacade.LOGGING_RB_NAME));
lr.setThreadID((int) Thread.currentThread().getId());
lr.setLoggerName(LogFacade.LOGGING_LOGGER_NAME);
EarlyLogHandler.earlyMessages.add(lr);
The issue is that earlier I was doing lr.setResourceBundleName(LogFacade.LOGGING_RB_NAME);
This resulted in the early messages appearing in the log file with just keys and without localization.
This was not working because the setResourceBundleName setter does not initialize the actual resource bundle used during logging but just initializes a String value.
So the resourceBundleName and the resourceBundle fields in the LogRecord class can go out of sync.
This is problematic from an API standpoint.
- relates to
-
JDK-4814565 (rb) add method to get basename from a ResourceBundle
- Resolved