deltaspike-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Struberg <strub...@yahoo.de>
Subject Re: NPE question for PropertyFileConfigSource
Date Wed, 25 Jan 2012 08:07:29 GMT
Hi!

Yes, that's not optimal ;)
I'd even rather 


throw new RuntimeException(e);

If there is a property file which cannot be read, then this might be a serious problem (the
app could react completely different depending on it)


LieGrue,
strub



----- Original Message -----
> From: Jason Porter <lightguard.jp@gmail.com>
> To: deltaspike-dev@incubator.apache.org
> Cc: 
> Sent: Wednesday, January 25, 2012 7:59 AM
> Subject: NPE question for PropertyFileConfigSource
> 
> As soon as I commit you'll see in rev 976dcbc the question I have, but for
> the sake of getting the conversation going I'll paste the method here:
> 
> private Properties loadProperties(URL url)
>     {
>         Properties props = new Properties();
> 
>         InputStream inputStream = null;
>         try
>         {
>             inputStream = url.openStream();
> 
>             if (inputStream != null)
>             {
>                 props.load(inputStream);
>             }
>         }
>         catch (IOException e)
>         {
>             return null; // TODO: Shouldn't this return an empty
> Properties? Otherwise we could cause NPE in the getPropertyValue method
>         }
>         finally
>         {
>             try
>             {
>                 if (inputStream != null)
>                 {
>                     inputStream.close();
>                 }
>             }
>             catch (IOException e)
>             {
>                 // no worries, means that the file is already closed
>             }
>         }
> 
>         return props;
>     }
> 
> -- 
> Jason Porter
> http://lightguard-jp.blogspot.com
> http://twitter.com/lightguardjp
> 
> Software Engineer
> Open Source Advocate
> Author of Seam Catch - Next Generation Java Exception Handling
> 
> PGP key id: 926CCFF5
> PGP key available at: keyserver.net, pgp.mit.edu
> 

Mime
View raw message