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 <[email protected]> > To: [email protected] > 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 >
