resource leak: FileInputStream was never closed

This commit is contained in:
radimch 2013-08-09 12:18:16 +02:00 committed by Norman Maurer
parent 65fd9c0b12
commit 9acf130adb

View File

@ -101,9 +101,11 @@ public class FileServer {
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');
}