浏览代码

use try-resource statement

Shinsuke Sugaya 9 年之前
父节点
当前提交
5d6aa4a70a

+ 3 - 1
src/main/java/org/codelibs/fess/app/web/admin/dict/kuromoji/AdminDictKuromojiAction.java

@@ -208,7 +208,9 @@ public class AdminDictKuromojiAction extends FessAdminAction {
         validate(form, messages -> {}, () -> downloadpage(form.dictId));
         return kuromojiService.getKuromojiFile(form.dictId).map(file -> {
             return asStream(new File(file.getPath()).getName()).contentType("text/plain; charset=UTF-8").stream(out -> {
-                out.write(file.getInputStream());
+                try (InputStream inputStream = file.getInputStream()) {
+                    out.write(inputStream);
+                }
             });
         }).orElseGet(() -> {
             throwValidationError(messages -> messages.addErrorsFailedToDownloadKuromojiFile(GLOBAL), () -> downloadpage(form.dictId));

+ 3 - 1
src/main/java/org/codelibs/fess/app/web/admin/dict/synonym/AdminDictSynonymAction.java

@@ -239,7 +239,9 @@ public class AdminDictSynonymAction extends FessAdminAction {
         validate(form, messages -> {}, () -> downloadpage(form.dictId));
         return synonymService.getSynonymFile(form.dictId).map(file -> {
             return asStream(new File(file.getPath()).getName()).contentType("text/plain; charset=UTF-8").stream(out -> {
-                out.write(file.getInputStream());
+                try (InputStream inputStream = file.getInputStream()) {
+                    out.write(inputStream);
+                }
             });
         }).orElseGet(() -> {
             throwValidationError(messages -> messages.addErrorsFailedToDownloadSynonymFile(GLOBAL), () -> downloadpage(form.dictId));