You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by lu...@apache.org on 2003/12/05 03:29:47 UTC

cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper JspC.java

luehe       2003/12/04 18:29:47

  Modified:    jasper2/src/share/org/apache/jasper JspC.java
  Log:
  Have JspC.execute() propagate its exceptions.
  
  In some cases, there used to be no way for a caller to determine
  whether an exception occurred, because some exceptions would be
  swallowed, and others would cause JspC.processFile() to return FALSE,
  but that return value could not be communicated to the callers of
  JspC.execute() (which is declared as void)
  
  Revision  Changes    Path
  1.62      +30 -57    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java
  
  Index: JspC.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- JspC.java	10 Nov 2003 22:26:20 -0000	1.61
  +++ JspC.java	5 Dec 2003 02:29:47 -0000	1.62
  @@ -182,7 +182,6 @@
       private String uriBase;
       private String uriRoot;
       private int dieLevel;
  -    private boolean dieOnExit = false;
       private boolean helpNeeded = false;
       private boolean compile = false;
       private String compiler = null;
  @@ -599,8 +598,7 @@
       /**
        * Include the generated web.xml inside the webapp's web.xml.
        */
  -    protected void mergeIntoWebXml()
  -        throws Exception {
  +    protected void mergeIntoWebXml() throws IOException {
   
           File webappBase = new File(uriRoot);
           File webXml = new File(webappBase, "WEB-INF/web.xml");
  @@ -701,7 +699,7 @@
   
       }
   
  -    public boolean processFile(String file)
  +    private void processFile(String file)
           throws JasperException
       {
           try {
  @@ -748,42 +746,24 @@
               if ( showSuccess ) {
                   log.info( "Built File: " + file );
               }
  -            return true;
  -        } catch (FileNotFoundException fne) {
  -	    if (log.isWarnEnabled()) {
  -		log.warn(Localizer.getMessage("jspc.error.fileDoesNotExist",
  -					      fne.getMessage()));
  -	    }
  -            throw new JasperException( fne );
  -        } catch (ServletException e) {
  -            Throwable rootCause = e;
  -            Throwable rootCauseCheck = null;
  -            // Extra aggressive rootCause finding
  -            do {
  -                if (rootCause instanceof ServletException) {
  -                    rootCauseCheck = 
  -                        ((ServletException) rootCause).getRootCause();
  -                    if (rootCauseCheck != null) {
  -                        rootCause = rootCauseCheck;
  -                        rootCauseCheck = null;
  -                    }
  -                }
  -            } while (rootCauseCheck != null);
  +
  +        } catch (JasperException je) {
  +            Throwable rootCause = je;
  +            while (rootCause instanceof JasperException
  +                    && ((JasperException) rootCause).getRootCause() != null) {
  +                rootCause = ((JasperException) rootCause).getRootCause();
  +            }
               log.error(Localizer.getMessage("jspc.error.generalException",
   					   file),
   		      rootCause);
  -            return false;
  +            throw je;
  +
           } catch (Exception e) {
  -            log.error(Localizer.getMessage("jspc.error.generalException",
  -					   file),
  -		      e);
  -            if ( listErrors ) {
  -	        log.warn( "Error in File: " + file, e );
  -		return true;
  -            } else if (dieLevel != NO_DIE_LEVEL) {
  -                dieOnExit = true;
  -            }
  -            throw new JasperException( "Error compiling " + file, e );
  +	    if ((e instanceof FileNotFoundException) && log.isWarnEnabled()) {
  +		log.warn(Localizer.getMessage("jspc.error.fileDoesNotExist",
  +					      e.getMessage()));
  +	    }
  +            throw new JasperException(e);
           }
       }
   
  @@ -830,7 +810,7 @@
           }
       }
   
  -    public void execute()  throws JasperException {
  +    public void execute() throws JasperException {
   
           try {
   	    if (uriRoot == null) {
  @@ -902,23 +882,17 @@
                   mergeIntoWebXml();
               }
   
  -        } catch (ServletException e) {
  -            Throwable rootCause = e;
  -            Throwable rootCauseCheck = null;
  -            // Extra aggressive rootCause finding
  -            do {
  -                if (rootCause instanceof ServletException) {
  -                    rootCauseCheck = 
  -                        ((ServletException) rootCause).getRootCause();
  -                    if (rootCauseCheck != null) {
  -                        rootCause = rootCauseCheck;
  -                        rootCauseCheck = null;
  -                    }
  -                }
  -            } while (rootCauseCheck != null);
  +        } catch (IOException ioe) {
  +            throw new JasperException(ioe);
  +
  +        } catch (JasperException je) {
  +            Throwable rootCause = je;
  +            while (rootCause instanceof JasperException
  +                    && ((JasperException) rootCause).getRootCause() != null) {
  +                rootCause = ((JasperException) rootCause).getRootCause();
  +            }
               rootCause.printStackTrace();
  -        } catch (Throwable t) {
  -            t.printStackTrace();
  +            throw je;
           }
       }
   
  @@ -1132,4 +1106,3 @@
           }
       }
   }
  -
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org