Skip to content

Commit ff02ad4

Browse files
committed
Close properly the InputStream in ScriptTemplateView#getTemplate()
Issue: SPR-13445
1 parent f2c9838 commit ff02ad4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateView.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import org.springframework.core.io.Resource;
4141
import org.springframework.core.io.ResourceLoader;
4242
import org.springframework.util.Assert;
43-
import org.springframework.util.StreamUtils;
43+
import org.springframework.util.FileCopyUtils;
4444
import org.springframework.util.StringUtils;
4545
import org.springframework.web.servlet.view.AbstractUrlBasedView;
4646

@@ -341,7 +341,8 @@ protected void renderMergedOutputModel(Map<String, Object> model, HttpServletReq
341341

342342
protected String getTemplate(String path) throws IOException {
343343
Resource resource = this.resourceLoader.getResource(path);
344-
return StreamUtils.copyToString(resource.getInputStream(), this.charset);
344+
InputStreamReader reader = new InputStreamReader(resource.getInputStream(), this.charset);
345+
return FileCopyUtils.copyToString(reader);
345346
}
346347

347348
}

0 commit comments

Comments
 (0)