HDFS-4017. Unclosed FileInputStream in GetJournalEditServlet. Contributed by Chao Shi.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-3077@1395727 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Todd Lipcon 2012-10-08 19:11:48 +00:00
parent 10a0eaaf0a
commit 70fc5cf01c
2 changed files with 7 additions and 2 deletions

View File

@ -84,3 +84,5 @@ HDFS-3955. QJM: Make acceptRecovery() atomic. (todd)
HDFS-3956. QJM: purge temporary files when no longer within retention period (todd)
HDFS-4004. TestJournalNode#testJournal fails because of test case execution order (Chao Shi via todd)
HDFS-4017. Unclosed FileInputStream in GetJournalEditServlet (Chao Shi via todd)

View File

@ -46,6 +46,7 @@
import org.apache.hadoop.hdfs.server.namenode.TransferFsImage;
import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo;
import org.apache.hadoop.hdfs.util.DataTransferThrottler;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.util.ServletUtil;
@ -157,6 +158,7 @@ private boolean checkStorageInfoOrSendError(JNStorage storage,
@Override
public void doGet(final HttpServletRequest request,
final HttpServletResponse response) throws ServletException, IOException {
FileInputStream editFileIn = null;
try {
final ServletContext context = getServletContext();
final Configuration conf = (Configuration) getServletContext()
@ -181,7 +183,6 @@ public void doGet(final HttpServletRequest request,
FileJournalManager fjm = storage.getJournalManager();
File editFile;
FileInputStream editFileIn;
synchronized (fjm) {
// Synchronize on the FJM so that the file doesn't get finalized
@ -209,6 +210,8 @@ public void doGet(final HttpServletRequest request,
String errMsg = "getedit failed. " + StringUtils.stringifyException(t);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, errMsg);
throw new IOException(errMsg);
} finally {
IOUtils.closeStream(editFileIn);
}
}