resource leak: FileInputStream was never closed
This commit is contained in:
parent
65fd9c0b12
commit
9acf130adb
@ -101,9 +101,11 @@ public class FileServer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ctx.write(file + " " + file.length() + '\n');
|
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.write(region);
|
||||||
ctx.writeAndFlush("\n");
|
ctx.writeAndFlush("\n");
|
||||||
|
fis.close();
|
||||||
} else {
|
} else {
|
||||||
ctx.writeAndFlush("File not found: " + file + '\n');
|
ctx.writeAndFlush("File not found: " + file + '\n');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user