kinman 2002/12/13 13:13:26 Modified: jasper2/src/share/org/apache/jasper/compiler JspReader.java Mark.java Log: - Fix 15337: Provide better error handling than an ArrayIndexOutOfBoundException Revision Changes Path 1.13 +25 -12 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java Index: JspReader.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- JspReader.java 5 Dec 2002 17:56:43 -0000 1.12 +++ JspReader.java 13 Dec 2002 21:13:25 -0000 1.13 @@ -132,7 +132,7 @@ singleFile = false; loghelper = new Logger.Helper("JASPER_LOG", "JspReader"); - pushFile2(fname, encoding, reader); + pushFile(fname, encoding, reader); } String getFile(int fileid) { @@ -315,7 +315,7 @@ int skipSpaces() throws JasperException { int i = 0; - while (isSpace()) { + while (hasMoreInput() && isSpace()) { i++; nextChar(); } @@ -532,7 +532,11 @@ return sourceFiles.size() - 1; } - private void pushFile2(String file, String encoding, + /** + * Push a file (and its associated Stream) on the file stack. THe + * current position in the current file is remembered. + */ + private void pushFile(String file, String encoding, InputStreamReader reader) throws JasperException, FileNotFoundException { @@ -574,29 +578,38 @@ } } + /** + * Pop a file from the file stack. The field "current" is retored + * to the value to point to the previous files, if any, and is set + * to null otherwise. + * @return true is there is a previous file on the stck. + * false otherwise. + */ private boolean popFile() throws JasperException { // Is stack created ? (will happen if the Jsp file we're looking at is // missing. - if (current == null) + if (current == null || currFileId < 0) { return false; + } // Restore parser state: - //size--; - if (currFileId < 0) { - err.jspError("jsp.error.no.more.content"); - } - String fName = getFile(currFileId); currFileId = unregisterSourceFile(fName); if (currFileId < -1) { err.jspError("jsp.error.file.not.registered", fName); } - boolean result = current.popStream(); - if (result) + Mark previous = current.popStream(); + if (previous != null) { master = current.baseDir; - return (result); + current = previous; + return true; + } + // Note that although the current file is undefined here, "current" + // is not set to null just for convience, for it maybe used to + // set the current (undefined) position. + return false; } } 1.3 +12 -9 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Mark.java Index: Mark.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Mark.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Mark.java 17 Oct 2002 20:43:06 -0000 1.2 +++ Mark.java 13 Dec 2002 21:13:25 -0000 1.3 @@ -189,13 +189,16 @@ stream = inStream; } - - - /** Restores this mark's state to a previously stored stream. + /** + /* Restores this mark's state to a previously stored stream. + * @return null if there is no previous stream + * The previous Makr instance when the stream is pushed. */ - public boolean popStream() { + public Mark popStream() { // make sure we have something to pop - if ( includeStack.size() <= 0 ) return false; + if ( includeStack.size() <= 0 ) { + return null; + } // get previous state in stack IncludeState state = (IncludeState) includeStack.pop( ); @@ -208,7 +211,7 @@ fileName = state.fileName; baseDir = state.baseDir; stream = state.stream; - return true; + return this; } // -------------------- Locator interface --------------------
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>