[ https://issues.apache.org/jira/browse/FLINK-4573?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15529194#comment-15529194 ]
ASF GitHub Bot commented on FLINK-4573: --------------------------------------- Github user zentol commented on a diff in the pull request: https://github.com/apache/flink/pull/2556#discussion_r80885477 --- Diff: flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/TaskManagerLogHandler.java --- @@ -210,7 +210,17 @@ public void onSuccess(Object filePathOption) throws Throwable { LOG.error("Displaying TaskManager log failed.", e); return; } - long fileLength = raf.length(); + long fileLength; + try { + fileLength = raf.length(); + } catch (IOException ioe) { + display(ctx, request, "Displaying TaskManager log failed."); + LOG.error("Displaying TaskManager log failed.", ioe); + if (raf != null) { --- End diff -- this should never be false, as we would otherwise get an NPE and would never enter this block. > Potential resource leak due to unclosed RandomAccessFile in > TaskManagerLogHandler > --------------------------------------------------------------------------------- > > Key: FLINK-4573 > URL: https://issues.apache.org/jira/browse/FLINK-4573 > Project: Flink > Issue Type: Bug > Reporter: Ted Yu > Priority: Minor > > {code} > try { > raf = new > RandomAccessFile(file, "r"); > } catch > (FileNotFoundException e) { > display(ctx, request, > "Displaying TaskManager log failed."); > LOG.error("Displaying > TaskManager log failed.", e); > return; > } > long fileLength = > raf.length(); > final FileChannel fc = > raf.getChannel(); > {code} > If length() throws IOException, raf would be left unclosed. -- This message was sent by Atlassian JIRA (v6.3.4#6332)