You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@abdera.apache.org by Garrett Rooney <ro...@electricjellyfish.net> on 2006/06/28 04:32:08 UTC

[PATCH] Check for null input streams (was Re: Getting started with Abdera)

On 6/27/06, James M Snell <ja...@gmail.com> wrote:
>
>
> Garrett Rooney wrote:
> >[snip]
> > That kind of error tends to result from passing a null stream to
> > parse().  When you say that the path to simple.xml was "valid", do you
> > mean you gave it a full system path, like:
> >
>
> Yep. I've seen this on several occasions and it always happens on a null
> stream.  We need to add some error checking on that

How about this?

-garrett

[[[
Check for null input streams in the parse() method.

[ in parser/src/main/java/org/apache/abdera/parser/stax ]

* FOMParser.java
  (parse): Throw an IllegalArgumentException if we are passed a null
   InputStream or Reader.
]]]

Re: [PATCH] Check for null input streams (was Re: Getting started with Abdera)

Posted by James M Snell <ja...@gmail.com>.
Patched!

Garrett Rooney wrote:
> On 6/27/06, James M Snell <ja...@gmail.com> wrote:
>>
>>
>> Garrett Rooney wrote:
>> >[snip]
>> > That kind of error tends to result from passing a null stream to
>> > parse().  When you say that the path to simple.xml was "valid", do you
>> > mean you gave it a full system path, like:
>> >
>>
>> Yep. I've seen this on several occasions and it always happens on a null
>> stream.  We need to add some error checking on that
> 
> How about this?
> 
> -garrett
> 
> [[[
> Check for null input streams in the parse() method.
> 
> [ in parser/src/main/java/org/apache/abdera/parser/stax ]
> 
> * FOMParser.java
>  (parse): Throw an IllegalArgumentException if we are passed a null
>   InputStream or Reader.
> ]]]
> 
> 
> ------------------------------------------------------------------------
> 
> Index: parser/src/main/java/org/apache/abdera/parser/stax/FOMParser.java
> ===================================================================
> --- parser/src/main/java/org/apache/abdera/parser/stax/FOMParser.java	(revision 417623)
> +++ parser/src/main/java/org/apache/abdera/parser/stax/FOMParser.java	(working copy)
> @@ -65,6 +65,10 @@
>      ParserOptions options)
>        throws ParseException {
>      Document<T> document = null;
> +
> +    if (in == null)
> +      throw new IllegalArgumentException("InputStream must not be null");
> +
>      try {
>        FOMFactory factory = getFomFactory(options);
>        FOMBuilder builder = new FOMBuilder(factory, in, options);
> @@ -83,6 +87,10 @@
>      ParserOptions options) 
>        throws ParseException {
>      Document<T> document = null;
> +
> +    if (in == null)
> +      throw new IllegalArgumentException("Reader must not be null");
> +
>      try {
>        FOMFactory factory = getFomFactory(options);
>        XMLStreamReader xmlreader =