resource leak: FileInputStream was never closed
This commit is contained in:
parent
65fd9c0b12
commit
9acf130adb
@ -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');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user