HDFS-4609. TestAuditLogs should release log handles between tests. Contributed by Ivan Mitic

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1459576 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tsz-wo Sze 2013-03-21 23:18:26 +00:00
parent 1b98d8dda3
commit e976294d35
2 changed files with 12 additions and 2 deletions

View File

@ -439,6 +439,9 @@ Release 2.0.5-beta - UNRELEASED
HDFS-4607. In TestGetConf.testGetSpecificKey(), use a platform-specific HDFS-4607. In TestGetConf.testGetSpecificKey(), use a platform-specific
line separator; otherwise, it fails on Windows. (Ivan Mitic via szetszwo) line separator; otherwise, it fails on Windows. (Ivan Mitic via szetszwo)
HDFS-4609. TestAuditLogs should release log handles between tests.
(Ivan Mitic via szetszwo)
Release 2.0.4-alpha - UNRELEASED Release 2.0.4-alpha - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -46,6 +46,7 @@ import org.apache.hadoop.hdfs.web.WebHdfsFileSystem;
import org.apache.hadoop.security.AccessControlException; import org.apache.hadoop.security.AccessControlException;
import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.UserGroupInformation;
import org.apache.log4j.Level; import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout; import org.apache.log4j.PatternLayout;
import org.apache.log4j.RollingFileAppender; import org.apache.log4j.RollingFileAppender;
@ -233,9 +234,15 @@ public class TestAuditLogs {
/** Sets up log4j logger for auditlogs */ /** Sets up log4j logger for auditlogs */
private void setupAuditLogs() throws IOException { private void setupAuditLogs() throws IOException {
// Shutdown the LogManager to release all logger open file handles.
// Unfortunately, Apache commons logging library does not provide
// means to release underlying loggers. For additional info look up
// commons library FAQ.
LogManager.shutdown();
File file = new File(auditLogFile); File file = new File(auditLogFile);
if (file.exists()) { if (file.exists()) {
file.delete(); assertTrue(file.delete());
} }
Logger logger = ((Log4JLogger) FSNamesystem.auditLog).getLogger(); Logger logger = ((Log4JLogger) FSNamesystem.auditLog).getLogger();
logger.setLevel(Level.INFO); logger.setLevel(Level.INFO);