From: Jim Procter Date: Fri, 11 Oct 2013 09:37:21 +0000 (+0100) Subject: JAL-1354 watch for exceptions when initialising (Security exceptions can occur in... X-Git-Tag: Release_2_8_1~4^2~23^2~9 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=04fa137fb5fba17c15133cb7b7d1b7706d99ea0d;p=jalview.git JAL-1354 watch for exceptions when initialising (Security exceptions can occur in the JalviewLite applet when running in default sandbox) --- diff --git a/src/jalview/util/MessageManager.java b/src/jalview/util/MessageManager.java index c5f0489..fcf2bfa 100644 --- a/src/jalview/util/MessageManager.java +++ b/src/jalview/util/MessageManager.java @@ -3,6 +3,7 @@ package jalview.util; import java.text.MessageFormat; import java.util.Locale; import java.util.ResourceBundle; +import java.util.logging.Level; import java.util.logging.Logger; /** @@ -18,17 +19,32 @@ public class MessageManager { private static Logger log=Logger.getLogger(MessageManager.class.getCanonicalName()); - private static Locale loc = Locale.getDefault(); + private static Locale loc; static{ + try { /* Localize Java dialogs */ - Locale.setDefault(loc); + loc = Locale.getDefault(); + // Locale.setDefault(loc); /* Getting messages for GV */ log.info("Getting messages for lang: "+loc); rb = ResourceBundle.getBundle("lang.Messages", loc); - log.finest("Language keys: "+rb.keySet()); + if (log.isLoggable(Level.FINEST)) { + // this might take a while, so we only do it if it will be shown + log.finest("Language keys: "+rb.keySet()); + } + } catch (Exception q) { + log.warning("Exception when initting Locale for i18n messages\n"+q.getMessage()); + q.printStackTrace(); + } + catch (Error v) + { + log.warning("Error when initting Locale for i18n messages\n"+v.getMessage()); + v.printStackTrace(); + } + } @@ -37,7 +53,7 @@ public class MessageManager { try{ value = rb.getString(key); }catch(Exception e){ - log.warning("I18N missing: "+loc+"\t"+key); + log.warning("I18N missing: "+loc+"\t"+key); } return value; }