Skip to content

Commit

Permalink
resource leak: FileInputStream was never closed
Browse files Browse the repository at this point in the history
  • Loading branch information
radimch authored and Norman Maurer committed Aug 14, 2013
1 parent 65fd9c0 commit 9acf130
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ public void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception
return;
}
ctx.write(file + " " + file.length() + '\n');
FileRegion region = new DefaultFileRegion(new FileInputStream(file).getChannel(), 0, file.length());
FileInputStream fis = new FileInputStream(file);
FileRegion region = new DefaultFileRegion(fis.getChannel(), 0, file.length());
ctx.write(region);
ctx.writeAndFlush("\n");
fis.close();
} else {
ctx.writeAndFlush("File not found: " + file + '\n');
}
Expand Down

0 comments on commit 9acf130

Please sign in to comment.