From 76b3a4ad16bd330cfa1d326eecdcae8a10db03fb Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov Date: Tue, 9 Nov 2010 14:14:47 +0000 Subject: Fixes a NullPointerException in smiley replacement. --- .../smiley/ReplacementServiceSmileyImpl.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/net/java/sip') diff --git a/src/net/java/sip/communicator/impl/replacement/smiley/ReplacementServiceSmileyImpl.java b/src/net/java/sip/communicator/impl/replacement/smiley/ReplacementServiceSmileyImpl.java index a238fc0..8e657ff 100644 --- a/src/net/java/sip/communicator/impl/replacement/smiley/ReplacementServiceSmileyImpl.java +++ b/src/net/java/sip/communicator/impl/replacement/smiley/ReplacementServiceSmileyImpl.java @@ -23,11 +23,17 @@ public class ReplacementServiceSmileyImpl implements SmiliesReplacementService { /** + * The Logger used by the ReplacementServiceSmileyImpl + * class and its instances for logging output. + */ + private static final Logger logger + = Logger.getLogger(ReplacementServiceSmileyImpl.class); + + /** * The List of smiley strings which are matched by * {@link #smileyRegex}. */ - private static final java.util.List smileyStrings = - new ArrayList(); + private static final List smileyStrings = new ArrayList(); /** * Configuration label shown in the config form. @@ -50,13 +56,17 @@ public class ReplacementServiceSmileyImpl { try { - return Resources.getSmiley(sourceString.trim()).getImagePath(); + Smiley smiley = Resources.getSmiley(sourceString.trim()); + + if (smiley != null) + return smiley.getImagePath(); } catch (Exception e) { - e.printStackTrace(); + logger.error( + "Failed to get smiley replacement for " + sourceString, + e); } - return sourceString; } @@ -164,4 +174,4 @@ public class ReplacementServiceSmileyImpl { Resources.reloadResources(); } -} \ No newline at end of file +} -- cgit v1.1