Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-6172

Potentially unclosed RandomAccessFile in HistoryServerStaticFileServerHandler

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3.0
    • Component/s: JobManager
    • Labels:
      None

      Description

          try {
            raf = new RandomAccessFile(file, "r");
          } catch (FileNotFoundException e) {
            StaticFileServerHandler.sendError(ctx, NOT_FOUND);
            return;
          }
          long fileLength = raf.length();
      

      raf should be closed in all possible execution paths.

        Activity

        Hide
        yuzhihong@gmail.com Ted Yu added a comment -

        Similar problem exists in StaticFileServerHandler.java

        Show
        yuzhihong@gmail.com Ted Yu added a comment - Similar problem exists in StaticFileServerHandler.java
        Hide
        Zentol Chesnay Schepler added a comment -

        according to the comment directly above the try block the RAF is closed automatically by netty.

        Show
        Zentol Chesnay Schepler added a comment - according to the comment directly above the try block the RAF is closed automatically by netty.
        Hide
        yuzhihong@gmail.com Ted Yu added a comment -

        RandomAccessFile#length() may throw IOE.

        DefaultFileRegion is only involved in this branch:

            if (ctx.pipeline().get(SslHandler.class) == null) {
              ctx.write(new DefaultFileRegion(raf.getChannel(), 0, fileLength), ctx.newProgressivePromise());
        

        not this branch:

            } else {
              lastContentFuture = ctx.writeAndFlush(new HttpChunkedInput(new ChunkedFile(raf, 0, fileLength, 8192)),
        
        Show
        yuzhihong@gmail.com Ted Yu added a comment - RandomAccessFile#length() may throw IOE. DefaultFileRegion is only involved in this branch: if (ctx.pipeline().get(SslHandler.class) == null ) { ctx.write( new DefaultFileRegion(raf.getChannel(), 0, fileLength), ctx.newProgressivePromise()); not this branch: } else { lastContentFuture = ctx.writeAndFlush( new HttpChunkedInput( new ChunkedFile(raf, 0, fileLength, 8192)),
        Show
        Zentol Chesnay Schepler added a comment - PR: https://github.com/apache/flink/pull/3678
        Hide
        yuzhihong@gmail.com Ted Yu added a comment -

        +1

        Show
        yuzhihong@gmail.com Ted Yu added a comment - +1
        Hide
        Zentol Chesnay Schepler added a comment -

        1.3: be26f7ed1e2b97bc2e6ab06d6267f8d542d78aee

        Show
        Zentol Chesnay Schepler added a comment - 1.3: be26f7ed1e2b97bc2e6ab06d6267f8d542d78aee

          People

          • Assignee:
            Zentol Chesnay Schepler
            Reporter:
            yuzhihong@gmail.com Ted Yu
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development