vy commented on code in PR #4218:
URL: https://github.com/apache/logging-log4j2/pull/4218#discussion_r3773649201
##########
log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/LoggerContextAdmin.java:
##########
@@ -128,17 +128,29 @@ public void setConfigLocationUri(final String
configLocation) throws URISyntaxEx
LOGGER.debug("---------");
LOGGER.debug("Remote request to reconfigure using location " +
configLocation);
final File configFile = new File(configLocation);
- ConfigurationSource configSource = null;
+ // ConfigurationSource(InputStream, File/URL) documents that the
caller owns the stream.
+ // XmlConfiguration, JsonConfiguration, and
PropertiesConfigurationFactory close
+ // getInputStream() when they consume it, but that is factory-side
cleanup. Keep a
+ // stream-backed source (so resetInputStream/reconfigure still
re-reads the file for
+ // monitorInterval) and always close the caller-owned stream via
try-with-resources.
if (configFile.exists()) {
LOGGER.debug("Opening config file {}",
configFile.getAbsolutePath());
- configSource = new ConfigurationSource(new
FileInputStream(configFile), configFile);
+ try (final InputStream in = new FileInputStream(configFile)) {
Review Comment:
Could you use `Files::newInputStream` instead, please?
--
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]