Use another try-with-resources.
@@ -58,7 +58,7 @@ public class PropertiesConfigurationTest {
@Test
public void testListAppender() throws Exception {
- LoggerContext loggerContext = configure("target/test-classes/log4j1-list.properties");
+ try (LoggerContext loggerContext = configure("target/test-classes/log4j1-list.properties")) {
Logger logger = LogManager.getLogger("test");
logger.debug("This is a test of the root logger");
Configuration configuration = loggerContext.getConfiguration();
@@ -79,6 +79,7 @@ public class PropertiesConfigurationTest {
List<String> messages = messageAppender.getMessages();
assertTrue("No messages", messages != null && messages.size() > 0);
}
+ }
@SuppressWarnings("resource")
private LoggerContext configure(String configLocation) throws Exception {
