cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Holz <h...@fiz-chemie.de>
Subject Re: NPE in URLSource under high load
Date Mon, 04 Feb 2002 16:35:51 GMT

Hi,

Chris Newland wrote:
> Hi All,
>
> I'm encountering a null pointer exception in the
> org.apache.cocoon.components.source.URLSource file when I run a stress test
> of my Cocoon 2 system:
>
> java.lang.NullPointerException
> 	at
> org.apache.cocoon.components.source.URLSource.getInfos(URLSource.java:95)
> 	at
> org.apache.cocoon.components.source.URLSource.getLastModified(URLSource.jav
>a
> <snip>

<snipped more>

> The code that throws the exception is: (from Cocoon 2.0 source, but
> identical in CVS snapshot 04/Feb/2002 (apart from some boolean
> optimizations))
>
>   /**
>      * Get the last modification date and content length of the source.
>      * Any exceptions are ignored.
>      */
>     private void getInfos() {
>         if (this.gotInfos == false) {
>             if (this.isFile == true) {
>                 File file = new File(systemId.substring(FILE.length()));
>                 this.lastModificationDate = file.lastModified();
>                 this.contentLength = file.length();
>             } else {
>                 try {
>                     if (this.connection == null) {
>                         this.connection = this.url.openConnection();
>                         String userInfo = this.getUserInfo();
>                         if (this.url.getProtocol().startsWith("http") ==
> true && userInfo != null) {
>
> this.connection.setRequestProperty("Authorization","Basic
> "+this.encodeBASE64(userInfo));
>                         }
>                     }
>                     this.lastModificationDate =
> this.connection.getLastModified();
> Line 95 ----->      this.contentLength =
> this.connection.getContentLength(); <------ NPE THROWN HERE
>                 } catch (IOException ignore) {
>                     this.lastModificationDate = 0;
>                     this.contentLength = -1;
>                 }
>             }
>             this.gotInfos = true;
>         }
>     }
>
> The exception results in the Tomcat Internal Server Error 500 page being
> shown and occurs about once in every 200 HTTP requests made by the stress
> testing tool (Paessler Webserver Stress Tool 5.2 Enterprise Edition).
>
> Looking at the code makes me think this might be a
> threading/synchronization bug as IMHO 'this.connection' is null and should
> have thrown the NPE on the previous line.
>
> I'll do my best to trace the problem's origin but I'm out of the country
> for 3 weeks as of tomorrow.
>
> Environment: SuSE 7.2, JDK 1.3.1_02, Cocoon 2.0 final, Tomcat 4.0.1,
> mod_webapp, Apache 1.3.22
>
> Stress testing tool is run from a remote client that hits the same 4 XSP
> pages in random order simulating 5 concurrent users.
>


If have noticed this from time to time too in Coccon 2.0 and 2.0.1.
Are you sure, the exception is in  this.connection.getContentLength() and not 
one line before in this.connection.getLastModified() ?
I believe,  this.url.openConnection() returns null instead of
throwing a IOException. Looks like a bug in the JDK.

However I have a different JDK:
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Classic VM (build 1.3.0, J2RE 1.3.0 IBM build cx130-20000815 (JIT enabled: 
jitc))

Don't know how the IBM JDK is related to Sun's  1.3.1_02.

Enviroment: SuSE 7.1,Linux  2.4.0-64GB-SMP, Dual Processor Intel, JDK see 
above, Cocoon 2.01, Tomcat 4.0.1.

Problem seems to happen more often with IE 5.5 than with Mozilla 0.97, maybe 
because IE is faster. Reloading the page always solves the problem.

Maybe, Cocoon should catch not only the IOException, but also the NPE.

--
Martin Holz  <holz@fiz-chemie.de>  phone: 0049-30-39977 218 
FIZ CHEMIE BERLIN




  

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message