Compare commits

...

4 Commits

Author SHA1 Message Date
Guus der Kinderen
834a6fe8a7 SPARK-2357: Don't consider every file ending with jpeg to be an image
Fixes an obvious mistake with file name handling.
2025-10-10 11:24:08 +02:00
Sergey Ponomarev
9c888f4fef Avoid NPE on getResourceAsStream() calls
When the resource i.g. properties file is not available the getResourceAsStream() returns null and this cuauses unhandled NPE.
2025-10-10 10:47:38 +02:00
Sergey Ponomarev
5349f7b519 Use Boolean.parseBoolean() instead of str.equalsIgnoreCase("true")
The parseBoolean() is null safe so we can remove the null checks.
2025-10-10 10:47:38 +02:00
Sergey Ponomarev
0d4987dc9b org.jivesoftware.resource.Default.getBoolean(): The replace(" ","") replaced with trim()
This was the intention. Also avoid NPE
2025-10-10 10:47:38 +02:00
6 changed files with 17 additions and 17 deletions

View File

@ -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 )
{ {

View File

@ -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 )
{ {
@ -181,7 +183,8 @@ public class Default {
} }
public static boolean getBoolean(String propertyName) { public static boolean getBoolean(String propertyName) {
return getString(propertyName).replace(" ","").equals("true"); String prop = getString(propertyName);
return prop != null && Boolean.parseBoolean(prop.trim());
} }
public static ImageIcon getImageIcon(String imageName) { public static ImageIcon getImageIcon(String imageName) {

View File

@ -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 )
{ {

View File

@ -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();
} }
@ -377,7 +379,7 @@ public class SparkRes {
while (enumeration.hasMoreElements()) { while (enumeration.hasMoreElements()) {
String token = enumeration.nextElement(); String token = enumeration.nextElement();
String value = prb.getProperty(token).toLowerCase(); String value = prb.getProperty(token).toLowerCase();
if (value.endsWith(".gif") || value.endsWith(".png") || value.endsWith(".jpg") || value.endsWith("jpeg")) { if (value.endsWith(".gif") || value.endsWith(".png") || value.endsWith(".jpg") || value.endsWith(".jpeg")) {
SparkRes.getImageIcon(token); SparkRes.getImageIcon(token);
} }
String str = "public static final String " + token + " = \"" + token + "\";\n"; String str = "public static final String " + token + " = \"" + token + "\";\n";

View File

@ -51,7 +51,7 @@ final public class FormUtils {
* otherwise. * otherwise.
*/ */
public static boolean isTrue(String str) { public static boolean isTrue(String str) {
return (str != null && str.equalsIgnoreCase("true")); return Boolean.parseBoolean(str);
} }

View File

@ -19,18 +19,9 @@ package net.java.sipmack.common;
/** /**
* Creates and writes out messages. * Creates and writes out messages.
*/ */
public class Log { public class Log {
private static boolean debugger = false; private static boolean debugger = Boolean.parseBoolean(System.getProperty("debugger"));
static {
if (System.getProperty("debugger") != null
&& System.getProperty("debugger").equals("true"))
debugger = true;
}
public static void debug(String message) { public static void debug(String message) {
if (debugger) if (debugger)