mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-10-29 03:34:43 +00:00
Avoid NPE on getResourceAsStream() calls
When the resource i.g. properties file is not available the getResourceAsStream() returns null and this cuauses unhandled NPE.
This commit is contained in:
parent
5349f7b519
commit
9c888f4fef
@ -40,7 +40,9 @@ public class ConfigurationRes {
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
InputStream resourceAsStream = cl.getResourceAsStream( "configuration.properties" );
|
InputStream resourceAsStream = cl.getResourceAsStream( "configuration.properties" );
|
||||||
prb.load( resourceAsStream );
|
if (resourceAsStream != null) {
|
||||||
|
prb.load( resourceAsStream );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
|
|||||||
@ -155,7 +155,9 @@ public class Default {
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
InputStream resourceAsStream = cl.getResourceAsStream( "default.properties" );
|
InputStream resourceAsStream = cl.getResourceAsStream( "default.properties" );
|
||||||
prb.load( resourceAsStream );
|
if (resourceAsStream != null) {
|
||||||
|
prb.load( resourceAsStream );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
|
|||||||
@ -37,7 +37,9 @@ public class SoundsRes {
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
InputStream resourceAsStream = cl.getResourceAsStream( "sounds.properties" );
|
InputStream resourceAsStream = cl.getResourceAsStream( "sounds.properties" );
|
||||||
prb.load( resourceAsStream );
|
if (resourceAsStream != null) {
|
||||||
|
prb.load( resourceAsStream );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
|
|||||||
@ -338,7 +338,9 @@ public class SparkRes {
|
|||||||
prb = new Properties();
|
prb = new Properties();
|
||||||
try {
|
try {
|
||||||
InputStream resourceAsStream = cl.getResourceAsStream("spark.properties");
|
InputStream resourceAsStream = cl.getResourceAsStream("spark.properties");
|
||||||
prb.load(resourceAsStream);
|
if (resourceAsStream != null) {
|
||||||
|
prb.load(resourceAsStream);
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user