logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject AbstractManager.release() -> AutoCloseable
Date Thu, 23 Jun 2016 23:23:37 GMT
I seems that AbstractManager should implement AutoCloseable where close()
does the same thing as release() and release() can be deprecated.

org.apache.logging.log4j.core.appender.AbstractManager.release()

This will let us rewrite things like the recently fixed
"OnStartupTriggeringPolicyTest
fails on Windows saying the file is used by another process"
https://issues.apache.org/jira/browse/LOG4J2-1445:

Is:

        final RollingFileManager manager =
RollingFileManager.getFileManager(TARGET_FILE, TARGET_PATTERN, true, false,
                policy, strategy, null, layout, 8192, true);
        try {
            manager.initialize();
            assertTrue(Files.exists(target));
            assertTrue(Files.size(target) == 0);
            assertTrue(Files.exists(rolled));
            assertTrue(Files.size(rolled) == size);
        } finally {
            manager.release();
        }

Could be:

        try (final RollingFileManager manager =
RollingFileManager.getFileManager(TARGET_FILE, TARGET_PATTERN, true, false,
                policy, strategy, null, layout, 8192, true)) {
            manager.initialize();
            assertTrue(Files.exists(target));
            assertTrue(Files.size(target) == 0);
            assertTrue(Files.exists(rolled));
            assertTrue(Files.size(rolled) == size);
        }

Thoughts?

Gary


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Mime
View raw message