From 04fa137fb5fba17c15133cb7b7d1b7706d99ea0d Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 11 Oct 2013 10:37:21 +0100 Subject: [PATCH] JAL-1354 watch for exceptions when initialising (Security exceptions can occur in the JalviewLite applet when running in default sandbox) --- src/jalview/util/MessageManager.java | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) 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; } -- 1.7.10.2