You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2017/10/09 17:16:05 UTC
logging-log4j2 git commit: [LOG4J2-2053] Exception
java.nio.charset.UnsupportedCharsetException: cp65001 in 2.9.0
Repository: logging-log4j2
Updated Branches:
refs/heads/master f01a5f09b -> 4457121ce
[LOG4J2-2053]
Exception java.nio.charset.UnsupportedCharsetException: cp65001 in 2.9.0
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/4457121c
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/4457121c
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/4457121c
Branch: refs/heads/master
Commit: 4457121cec465cf0f738290f2ff3ab1142ad286c
Parents: f01a5f0
Author: Gary Gregory <gg...@apache.org>
Authored: Mon Oct 9 11:16:02 2017 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Mon Oct 9 11:16:02 2017 -0600
----------------------------------------------------------------------
.../logging/log4j/util/PropertiesUtil.java | 6 ++-
.../log4j/util/Log4jCharsetsPropertiesTest.java | 45 ++++++++++++++++++++
2 files changed, 50 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4457121c/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
index 6dae543..85ee9d6 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
@@ -191,7 +191,7 @@ public final class PropertiesUtil {
if (Charset.isSupported(charsetName)) {
return Charset.forName(charsetName);
}
- ResourceBundle bundle = ResourceBundle.getBundle("Log4j-charsets");
+ ResourceBundle bundle = getCharsetsResourceBundle();
if (bundle.containsKey(name)) {
String mapped = bundle.getString(name);
if (Charset.isSupported(mapped)) {
@@ -348,6 +348,10 @@ public final class PropertiesUtil {
return subset;
}
+ static ResourceBundle getCharsetsResourceBundle() {
+ return ResourceBundle.getBundle("Log4j-charsets");
+ }
+
/**
* Partitions a properties map based on common key prefixes up to the first period.
*
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4457121c/log4j-api/src/test/java/org/apache/logging/log4j/util/Log4jCharsetsPropertiesTest.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/util/Log4jCharsetsPropertiesTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/util/Log4jCharsetsPropertiesTest.java
new file mode 100644
index 0000000..ff8fd5f
--- /dev/null
+++ b/log4j-api/src/test/java/org/apache/logging/log4j/util/Log4jCharsetsPropertiesTest.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.util;
+
+import java.nio.charset.Charset;
+import java.util.Enumeration;
+import java.util.ResourceBundle;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class Log4jCharsetsPropertiesTest {
+
+ /**
+ * Tests that we can load all mappings.
+ */
+ @Test
+ public void testLoadAll() {
+ ResourceBundle resourceBundle = PropertiesUtil.getCharsetsResourceBundle();
+ Enumeration<String> keys = resourceBundle.getKeys();
+ while (keys.hasMoreElements()) {
+ String key = keys.nextElement();
+ Assert.assertFalse(String.format("The Charset %s is available and should not be mapped", key),
+ Charset.isSupported(key));
+ String value = resourceBundle.getString(key);
+ Assert.assertTrue(String.format("The Charset %s is is not available and is mapped from %s", value, key),
+ Charset.isSupported(value));
+ }
+ }
+}