Author: markt Date: Tue May 16 13:35:39 2017 New Revision: 1795308 URL: http://svn.apache.org/viewvc?rev=1795308&view=rev Log: Simplify code
No need to wrap BufferedInputStream in another BufferedInputStream Modified: tomcat/trunk/java/org/apache/jasper/compiler/EncodingDetector.java tomcat/trunk/java/org/apache/jasper/compiler/ParserController.java Modified: tomcat/trunk/java/org/apache/jasper/compiler/EncodingDetector.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/EncodingDetector.java?rev=1795308&r1=1795307&r2=1795308&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/EncodingDetector.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/EncodingDetector.java Tue May 16 13:35:39 2017 @@ -43,15 +43,8 @@ class EncodingDetector { private final boolean encodingSpecifiedInProlog; - /* - * TODO: Refactor Jasper InputStream creation and handling so the - * InputStream passed to this method is buffered and therefore saves - * on multiple opening and re-opening of the same file. - */ - EncodingDetector(InputStream is) throws IOException { - // Keep buffer size to a minimum here. BoM will be no more than 4 bytes - // so that is the maximum we need to buffer - BufferedInputStream bis = new BufferedInputStream(is, 4); + EncodingDetector(BufferedInputStream bis) throws IOException { + // Buffer is 1k. BOM is only 4 bytes. bis.mark(4); BomResult bomResult = processBom(bis); Modified: tomcat/trunk/java/org/apache/jasper/compiler/ParserController.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/ParserController.java?rev=1795308&r1=1795307&r2=1795308&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/ParserController.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/ParserController.java Tue May 16 13:35:39 2017 @@ -16,9 +16,9 @@ */ package org.apache.jasper.compiler; +import java.io.BufferedInputStream; import java.io.FileNotFoundException; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; import java.util.Stack; @@ -318,8 +318,8 @@ class ParserController implements TagCon sourceEnc = "ISO-8859-1"; } else { // XML syntax or unknown, (auto)detect encoding ... - InputStream inStream = JspUtil.getInputStream(absFileName, jar, ctxt); - EncodingDetector encodingDetector = new EncodingDetector(inStream); + BufferedInputStream bis = JspUtil.getInputStream(absFileName, jar, ctxt); + EncodingDetector encodingDetector = new EncodingDetector(bis); sourceEnc = encodingDetector.getEncoding(); isEncodingSpecifiedInProlog = encodingDetector.isEncodingSpecifiedInProlog(); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org