tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <wbar...@wilshire.com>
Subject Re: [PATCH] TC 3.3 WebXmlReader.java
Date Thu, 29 Nov 2001 03:44:37 GMT
Since I had the file open anyway, I've gone ahead and put this one in as
well.
----- Original Message -----
From: "Schreibman, David" <DSchreibman@eTranslate.com>
To: "'Tomcat Developers List'" <tomcat-dev@jakarta.apache.org>
Sent: Friday, November 09, 2001 9:27 AM
Subject: RE: [PATCH] TC 3.3 WebXmlReader.java


> Ouch!  Here it is again without the lame null pointer exception :))
>
> -David
>
>
>
> > -----Original Message-----
> > From: Schreibman, David
> > Sent: Friday, November 02, 2001 1:04 PM
> > To: 'Tomcat Developers List'
> > Subject: RE: [PATCH] TC 3.3 WebXmlReader.java
> >
> >
> > Cool.
> >
> > If and when you decide to check it in, you might want to
> > consider this minor update applying the same logic to the
> > error handler's warning method.  The previously posted patch
> > only covered calls the to error handler's error and
> > fatalError methods.  I couldn't make up my mind as to whether
> > parser warnings should impose the same startup penalty but
> > now think it might be a good idea.
> >
> > -David
> >
> >
> >
> > > -----Original Message-----
> > > From: cmanolache@yahoo.com [mailto:cmanolache@yahoo.com]
> > > Sent: Friday, November 02, 2001 8:33 AM
> > > To: Tomcat Developers List
> > > Subject: Re: [PATCH] TC 3.3 WebXmlReader.java
> > >
> > >
> > > On Fri, 2 Nov 2001, Bojan Smojver wrote:
> > >
> > > > Notice that here, only the second time around things go bad
> > > (at context
> > > > reload) and that's only sometimes. Normally, there is
> > nothing in the
> > > > logs. Weird...
> > > >
> > > > I'll have to dig into it to find out what it really is. I
> > > might apply
> > > > this patch to my local build, just to see if it makes any
> > > difference.
> > >
> > > The patch seems ok to me ( thanks David !) - I was planning
> > > to check it
> > > in. If you find any problem let me know.
> > >
> > > I added this 'validation mark' to avoid the expensive
> > > validation if the
> > > file was already validated before. Since tomcat can ( or
> > > should be able to
> > > ) tolerate some errors in web.xml everything should still
> > > work - but you
> > > get the warning that the file have errors like bad ordering
> > > of elements.
> > >
> > > Without the patch you get the warning only once ( or after each
> > > modification of web.xml ). With the patch you'll be warned on
> > > each server
> > > startup and the startup time will be longer until you fix web.xml -
> > > which should give time to read the warnings and be the punishment.
> > >
> > >
> > > Costin
> > >
> > >
> > >
> > > > > Some people I work with noticed that Tomcat was spitting
> > > out a web.xml
> > > > > validation error for their app, but only the first time
> > > they started up.
> > > > > This gave them the impression that everything was ok the
> > > second time.
> > > > >
> > > > > Well, I looked around a bit and found that WebXmlReader
> > > writes out a
> > > > > "validation mark" (webxmlval.txt) in the work directory.
> > > The timestamp of
> > > > > the validation mark is used as part of deciding whether
> > > to validate.  The
> > > > > thing is, this mark is written out even if web.xml was
> > > not valid so next
> > > > > time through validation is skipped.
> > > > >
> > > > > I'm not sure if this was done on purpose and I can even
> > > imagine an argument
> > > > > about not nagging more than once.  Still, in our case the
> > > disappearance of
> > > > > the validation errors brought about false confidence.
> > > > >
> > > > > In case this seems like a problem to anyone else, here's
> > > a patch that only
> > > > > writes out the validation mark if the XML parsed without
> > > errors.  That way
> > > > > you keep seeing the validation errors until you a)
> > > disable validation or b)
> > > > > fix the offending xml.
> > > > >
> > > > > Interestingly, this patch takes advantage of an unused
> > > boolean field in the
> > > > > error handler.  Makes me wonder if somebody already
> > > thought of this but
> > > > > decided not to deal with it.  Perhaps there was a good reason.
> > > > >
> > > > > Regards,
> > > > >
> > > > > -David
> > > > >
> > > > >
> > > > >
> > > > >
> > > --------------------------------------------------------------
> > > ----------
> > > > >
> > > > > --- WebXmlReader.java.orig Wed Oct 31 13:00:07 2001
> > > > > +++ WebXmlReader.java Wed Oct 31 12:12:55 2001
> > > > > @@ -99,7 +99,7 @@
> > > > >      static class WebXmlErrorHandler implements ErrorHandler{
> > > > >  Context ctx;
> > > > >  XmlMapper xm;
> > > > > - boolean ok;
> > > > > + boolean ok = true;
> > > > >  WebXmlErrorHandler( XmlMapper xm,Context ctx ) {
> > > > >      this.ctx=ctx;
> > > > >      this.xm=xm;
> > > > > @@ -113,16 +113,21 @@
> > > > >  public void error (SAXParseException exception)
> > > > >      throws SAXException
> > > > >  {
> > > > > +     ok = false;
> > > > >      ctx.log("web.xml: Error " + exception );
> > > > >      ctx.log(xm.positionToString());
> > > > >  }
> > > > >  public void fatalError (SAXParseException exception)
> > > > >      throws SAXException
> > > > >  {
> > > > > +     ok = false;
> > > > >      ctx.log("web.xml: Fatal error " + exception );
> > > > >      ctx.log(xm.positionToString());
> > > > >      throw new SAXException( "Fatal error " +
> > exception );
> > > > >  }
> > > > > + public boolean isOk() {
> > > > > +     return ok;
> > > > > + }
> > > > >      }
> > > > >
> > > > >      void processWebXmlFile( Context ctx, String file) {
> > > > > @@ -134,13 +139,15 @@
> > > > >      }
> > > > >      if( ctx.getDebug() > 0 ) ctx.log("Reading "
> > + file );
> > > > >      XmlMapper xh=new XmlMapper();
> > > > > +     WebXmlErrorHandler xeh = null;
> > > > >      File v=new File( ctx.getWorkDir(),
> > "webxmlval.txt" );
> > > > >      if( validate ) {
> > > > >  if( ! v.exists() ||
> > > > >      v.lastModified() < f.lastModified() ) {
> > > > >      ctx.log("Validating web.xml");
> > > > >      xh.setValidating(true);
> > > > > -     xh.setErrorHandler( new WebXmlErrorHandler(
> > > xh, ctx ) );
> > > > > +     xeh = new WebXmlErrorHandler( xh, ctx );
> > > > > +     xh.setErrorHandler( xeh );
> > > > >  }
> > > > >      }
> > > > >
> > > > > @@ -230,7 +237,8 @@
> > > > >
> > > > >      Object ctx1=xh.readXml(f, ctx);
> > > > >
> > > > > -     if( validate ) {
> > > > > +     if( validate && xeh.isOk()) {
> > > > > + // don't create/update the validation mark if
> > > an error was detected
> > > > >  try {
> > > > >      FileOutputStream fos=new
> > FileOutputStream( v );
> > > > >      fos.write( 1 );
> > > > >
> > > > >
> > > > >
> > > > >
> > > --------------------------------------------------------------
> > > ----------
> > > > >
> > > > > --
> > > > > To unsubscribe, e-mail:
> > > <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
> > > > > For additional commands, e-mail:
> > > <mailto:tomcat-dev-help@jakarta.apache.org>
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > <mailto:tomcat-dev-help@jakarta.apache.org>
> > > >
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
> > > For additional commands, e-mail:
> > > <mailto:tomcat-dev-help@jakarta.apache.org>
> > >
> >
>
>


----------------------------------------------------------------------------
----


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


*----*

This message is intended only for the use of the person(s) listed above 
as the intended recipient(s), and may contain information that is 
PRIVILEGED and CONFIDENTIAL.  If you are not an intended recipient, 
you may not read, copy, or distribute this message or any attachment.  
If you received this communication in error, please notify us immediately 
by e-mail and then delete all copies of this message and any attachments.


In addition you should be aware that ordinary (unencrypted) e-mail sent 
through the Internet is not secure. Do not send confidential or sensitive 
information, such as social security numbers, account numbers, personal 
identification numbers and passwords, to us via ordinary (unencrypted) 
e-mail. 

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


Mime
View raw message