From a27b79444173d700d5b86a39df5929392c7fd78d Mon Sep 17 00:00:00 2001 From: Karsten Lehmann Date: Wed, 13 Mar 2019 11:29:47 +0100 Subject: [PATCH 1/2] Catch AccessControlException reading env variable with SecurityManager --- src/com/unboundid/util/StaticUtils.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/com/unboundid/util/StaticUtils.java b/src/com/unboundid/util/StaticUtils.java index cc4715e1f..123bcee3d 100644 --- a/src/com/unboundid/util/StaticUtils.java +++ b/src/com/unboundid/util/StaticUtils.java @@ -123,17 +123,15 @@ public final class StaticUtils // Try to dynamically determine the size of the terminal window using the // COLUMNS environment variable. int terminalWidth = 80; - final String columnsEnvVar = System.getenv("COLUMNS"); - if (columnsEnvVar != null) - { - try - { + try { + final String columnsEnvVar = System.getenv("COLUMNS"); + if (columnsEnvVar != null) { terminalWidth = Integer.parseInt(columnsEnvVar); } - catch (final Exception e) - { - Debug.debugException(e); - } + } + catch (final Exception e) + { + Debug.debugException(e); } TERMINAL_WIDTH_COLUMNS = terminalWidth; From f448035ea0e20df1520b46f8cdbac68094794ccf Mon Sep 17 00:00:00 2001 From: Karsten Lehmann Date: Wed, 13 Mar 2019 14:39:55 +0100 Subject: [PATCH 2/2] Catch AccessControlException changing log level with SecurityManager --- src/com/unboundid/util/Debug.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/com/unboundid/util/Debug.java b/src/com/unboundid/util/Debug.java index 7169bf445..bb9bd35aa 100644 --- a/src/com/unboundid/util/Debug.java +++ b/src/com/unboundid/util/Debug.java @@ -215,7 +215,12 @@ public static void initialize() debugEnabled = false; debugTypes = EnumSet.allOf(DebugType.class); - logger.setLevel(Level.ALL); + try { + logger.setLevel(Level.ALL); + } + catch (final Exception e) { + // + } } @@ -309,7 +314,13 @@ else if (stackProp.equalsIgnoreCase("false")) final String levelProp = properties.getProperty(PROPERTY_DEBUG_LEVEL); if ((levelProp != null) && (! levelProp.isEmpty())) { - logger.setLevel(Level.parse(levelProp)); + try { + logger.setLevel(Level.parse(levelProp)); + } + catch (final Exception e) { + logger.log(Level.WARNING, "Could not change log level to "+ + levelProp, e); + } } }