From ff02ad47e0d69e162b329a8e2e0ba0b78e45bc1f Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Tue, 8 Sep 2015 17:21:44 +0200 Subject: [PATCH] Close properly the InputStream in ScriptTemplateView#getTemplate() Issue: SPR-13445 --- .../web/servlet/view/script/ScriptTemplateView.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateView.java index 5712b3807c..0086237cbe 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateView.java @@ -40,7 +40,7 @@ import org.springframework.core.io.DefaultResourceLoader; import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; import org.springframework.util.Assert; -import org.springframework.util.StreamUtils; +import org.springframework.util.FileCopyUtils; import org.springframework.util.StringUtils; import org.springframework.web.servlet.view.AbstractUrlBasedView; @@ -341,7 +341,8 @@ public class ScriptTemplateView extends AbstractUrlBasedView { protected String getTemplate(String path) throws IOException { Resource resource = this.resourceLoader.getResource(path); - return StreamUtils.copyToString(resource.getInputStream(), this.charset); + InputStreamReader reader = new InputStreamReader(resource.getInputStream(), this.charset); + return FileCopyUtils.copyToString(reader); } }