You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2014/10/27 23:21:41 UTC
svn commit: r1634706 -
/tomcat/trunk/java/org/apache/jasper/compiler/JspReader.java
Author: markt
Date: Mon Oct 27 22:21:41 2014
New Revision: 1634706
URL: http://svn.apache.org/r1634706
Log:
pushFile() is only called from one location so move the code to that
location (since it will allow further simplication).
Modified:
tomcat/trunk/java/org/apache/jasper/compiler/JspReader.java
Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspReader.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JspReader.java?rev=1634706&r1=1634705&r2=1634706&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/JspReader.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/JspReader.java Mon Oct 27 22:21:41 2014
@@ -120,9 +120,57 @@ class JspReader {
this.err = err;
sourceFiles = new Vector<>();
currFileId = 0;
- pushFile(fname, reader);
+
+ int fileid = registerSourceFile(fname);
+
+ if (fileid == -1) {
+ // http://issues.apache.org/bugzilla/show_bug.cgi?id=37407
+ try {
+ reader.close();
+ } catch (Exception any) {
+ if(log.isDebugEnabled()) {
+ log.debug("Exception closing reader: ", any);
+ }
+ }
+
+ err.jspError("jsp.error.file.already.registered", fname);
+ }
+
+ currFileId = fileid;
+
+ try {
+ CharArrayWriter caw = new CharArrayWriter();
+ char buf[] = new char[1024];
+ for (int i = 0 ; (i = reader.read(buf)) != -1 ;)
+ caw.write(buf, 0, i);
+ caw.close();
+ if (current == null) {
+ current = new Mark(this, caw.toCharArray(), fileid,
+ getFile(fileid), master);
+ } else {
+ current.pushStream(caw.toCharArray(), fileid, getFile(fileid),
+ fname);
+ }
+ } catch (Throwable ex) {
+ ExceptionUtils.handleThrowable(ex);
+ log.error("Exception parsing file ", ex);
+ // Pop state being constructed:
+ popFile();
+ err.jspError("jsp.error.file.cannot.read", fname);
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (Exception any) {
+ if(log.isDebugEnabled()) {
+ log.debug("Exception closing reader: ", any);
+ }
+ }
+ }
+ }
}
+
/**
* @return JSP compilation context with which this JspReader is
* associated
@@ -647,65 +695,6 @@ class JspReader {
}
/**
- * 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,
- InputStreamReader reader) throws JasperException {
-
- // Register the file
- String longName = file;
-
- int fileid = registerSourceFile(longName);
-
- if (fileid == -1) {
- // http://issues.apache.org/bugzilla/show_bug.cgi?id=37407
- try {
- reader.close();
- } catch (Exception any) {
- if(log.isDebugEnabled()) {
- log.debug("Exception closing reader: ", any);
- }
- }
-
- err.jspError("jsp.error.file.already.registered", file);
- }
-
- currFileId = fileid;
-
- try {
- CharArrayWriter caw = new CharArrayWriter();
- char buf[] = new char[1024];
- for (int i = 0 ; (i = reader.read(buf)) != -1 ;)
- caw.write(buf, 0, i);
- caw.close();
- if (current == null) {
- current = new Mark(this, caw.toCharArray(), fileid,
- getFile(fileid), master);
- } else {
- current.pushStream(caw.toCharArray(), fileid, getFile(fileid),
- longName);
- }
- } catch (Throwable ex) {
- ExceptionUtils.handleThrowable(ex);
- log.error("Exception parsing file ", ex);
- // Pop state being constructed:
- popFile();
- err.jspError("jsp.error.file.cannot.read", file);
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (Exception any) {
- if(log.isDebugEnabled()) {
- log.debug("Exception closing reader: ", any);
- }
- }
- }
- }
- }
-
- /**
* Pop a file from the file stack. The field "current" is restored
* to the value to point to the previous files, if any, and is set
* to null otherwise.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org