mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-10-30 04:11:39 +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,8 +40,10 @@ public class ConfigurationRes {
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
InputStream resourceAsStream = cl.getResourceAsStream( "configuration.properties" );
|
InputStream resourceAsStream = cl.getResourceAsStream( "configuration.properties" );
|
||||||
|
if (resourceAsStream != null) {
|
||||||
prb.load( resourceAsStream );
|
prb.load( resourceAsStream );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@ -155,8 +155,10 @@ public class Default {
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
InputStream resourceAsStream = cl.getResourceAsStream( "default.properties" );
|
InputStream resourceAsStream = cl.getResourceAsStream( "default.properties" );
|
||||||
|
if (resourceAsStream != null) {
|
||||||
prb.load( resourceAsStream );
|
prb.load( resourceAsStream );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@ -37,8 +37,10 @@ public class SoundsRes {
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
InputStream resourceAsStream = cl.getResourceAsStream( "sounds.properties" );
|
InputStream resourceAsStream = cl.getResourceAsStream( "sounds.properties" );
|
||||||
|
if (resourceAsStream != null) {
|
||||||
prb.load( resourceAsStream );
|
prb.load( resourceAsStream );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@ -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");
|
||||||
|
if (resourceAsStream != null) {
|
||||||
prb.load(resourceAsStream);
|
prb.load(resourceAsStream);
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user