You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@forrest.apache.org by Gavin <ga...@16degrees.com.au> on 2008/09/15 13:31:40 UTC

RE: svn commit: r695423 - /forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/XMLStructurer.java


> -----Original Message-----
> From: thorsten@apache.org [mailto:thorsten@apache.org]
> Sent: Monday, 15 September 2008 9:04 PM
> To: svn@forrest.apache.org
> Subject: svn commit: r695423 -
> /forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/im
> pl/XMLStructurer.java
> 
> Author: thorsten
> Date: Mon Sep 15 04:04:10 2008
> New Revision: 695423
> 
> URL: http://svn.apache.org/viewvc?rev=695423&view=rev
> Log:
> Fixing possible NPE.
> 
> Modified:
> 
> forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/imp
> l/XMLStructurer.java
> 
> Modified:
> forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/imp
> l/XMLStructurer.java
> URL:
> http://svn.apache.org/viewvc/forrest/trunk/whiteboard/dispatcher/java/org/
> apache/forrest/dispatcher/impl/XMLStructurer.java?rev=695423&r1=695422&r2=
> 695423&view=diff
> ==========================================================================
> ====
> ---
> forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/imp
> l/XMLStructurer.java (original)
> +++
> forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/imp
> l/XMLStructurer.java Mon Sep 15 04:04:10 2008
> @@ -190,7 +190,9 @@
>          this.contractUriPrefix + name + this.contractUriSufix);
>      contract.initializeFromStream(xslStream);
>      // closing stream
> -    xslStream.close();
> +    if(xslStream!=null){
> +      xslStream.close();
> +    }
>      /*
>       * HACK END
>       */
> @@ -203,7 +205,9 @@
>          elementName = reader.getLocalName();
>          if (elementName.equals(CONTRACT_ELEMENT)) {
>            InputStream resultStream = contract.execute(dataStream, param);
> -          dataStream.close();

> +          if (null!=dataStream){

Should that not be the other way around ?

Just checking

Gav...

> +            dataStream.close();
> +          }
>            // FIXME: add the stream to the result map with the actual path
>            process = false;
>          }
> 
> 
> 
> --
> No virus found in this incoming message.
> Checked by AVG.
> Version: 7.5.524 / Virus Database: 270.6.21 - Release Date: 9/11/2008
> 12:00 AM


RE: svn commit: r695423 - /forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/XMLStructurer.java

Posted by Thorsten Scherler <th...@apache.org>.
On Mon, 2008-09-15 at 16:46 +0200, Thorsten Scherler wrote:
> On Mon, 2008-09-15 at 21:31 +1000, Gavin wrote:
> ...
> > > New Revision: 695423
> > > 
> > > URL: http://svn.apache.org/viewvc?rev=695423&view=rev
> > > Log:
> > > Fixing possible NPE.
> > > 
> > > Modified:
> > > ...
> > > -    xslStream.close();
> > > +    if(xslStream!=null){
> > > +      xslStream.close();
> > > +    }
> > >      /*
> > >       * HACK END
> > >       */
> > > @@ -203,7 +205,9 @@
> > >          elementName = reader.getLocalName();
> > >          if (elementName.equals(CONTRACT_ELEMENT)) {
> > >            InputStream resultStream = contract.execute(dataStream, param);
> > > -          dataStream.close();
> > 
> > > +          if (null!=dataStream){
> > 
> > Should that not be the other way around ?
> 
> Hmm, no, because if the dataStream is null, one cannot close it. That
> would throw a NPE.

Rereading your and mine answer:

null!=dataStream is the same as dataStream!=null

salu2

> 
> Cheers for checking.
> 
> salu2
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java                      consulting, training and solutions


RE: svn commit: r695423 - /forrest/trunk/whiteboard/dispatcher/java/org/apache/forrest/dispatcher/impl/XMLStructurer.java

Posted by Thorsten Scherler <th...@apache.org>.
On Mon, 2008-09-15 at 21:31 +1000, Gavin wrote:
...
> > New Revision: 695423
> > 
> > URL: http://svn.apache.org/viewvc?rev=695423&view=rev
> > Log:
> > Fixing possible NPE.
> > 
> > Modified:
> > ...
> > -    xslStream.close();
> > +    if(xslStream!=null){
> > +      xslStream.close();
> > +    }
> >      /*
> >       * HACK END
> >       */
> > @@ -203,7 +205,9 @@
> >          elementName = reader.getLocalName();
> >          if (elementName.equals(CONTRACT_ELEMENT)) {
> >            InputStream resultStream = contract.execute(dataStream, param);
> > -          dataStream.close();
> 
> > +          if (null!=dataStream){
> 
> Should that not be the other way around ?

Hmm, no, because if the dataStream is null, one cannot close it. That
would throw a NPE.

Cheers for checking.

salu2
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java                      consulting, training and solutions