diff -Nru jboss-logging-3.3.0/debian/changelog jboss-logging-3.3.1/debian/changelog --- jboss-logging-3.3.0/debian/changelog 2016-12-23 23:52:05.000000000 +0000 +++ jboss-logging-3.3.1/debian/changelog 2017-06-20 10:23:27.000000000 +0000 @@ -1,3 +1,11 @@ +jboss-logging (3.3.1-1) unstable; urgency=medium + + * New upstream version 3.3.1. + * Declare compliance with Debian Policy 4.0.0. + * Update copyright years. + + -- Markus Koschany Tue, 20 Jun 2017 12:23:27 +0200 + jboss-logging (3.3.0-2) unstable; urgency=medium * Switch to compat level 10. diff -Nru jboss-logging-3.3.0/debian/control jboss-logging-3.3.1/debian/control --- jboss-logging-3.3.0/debian/control 2016-12-23 23:52:05.000000000 +0000 +++ jboss-logging-3.3.1/debian/control 2017-06-20 10:23:27.000000000 +0000 @@ -14,7 +14,7 @@ libmaven-bundle-plugin-java, libmaven-javadoc-plugin-java, maven-debian-helper (>= 1.5) -Standards-Version: 3.9.8 +Standards-Version: 4.0.0 Vcs-Git: https://anonscm.debian.org/git/pkg-java/jboss-logging.git Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/jboss-logging.git Homepage: http://www.jboss.org diff -Nru jboss-logging-3.3.0/debian/copyright jboss-logging-3.3.1/debian/copyright --- jboss-logging-3.3.0/debian/copyright 2016-12-23 23:52:05.000000000 +0000 +++ jboss-logging-3.3.1/debian/copyright 2017-06-20 10:23:27.000000000 +0000 @@ -1,4 +1,4 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: JBoss Logging 3 Source: https://github.com/jboss-logging/jboss-logging @@ -7,7 +7,7 @@ License: Apache-2.0 Files: debian/* -Copyright: 2015-2016, Markus Koschany +Copyright: 2015-2017, Markus Koschany License: Apache-2.0 License: Apache-2.0 diff -Nru jboss-logging-3.3.0/pom.xml jboss-logging-3.3.1/pom.xml --- jboss-logging-3.3.0/pom.xml 2015-05-28 16:49:04.000000000 +0000 +++ jboss-logging-3.3.1/pom.xml 2017-03-15 20:21:35.000000000 +0000 @@ -5,7 +5,7 @@ 4.0.0 org.jboss.logging jboss-logging - 3.3.0.Final + 3.3.1.Final jar JBoss Logging 3 http://www.jboss.org @@ -128,6 +128,7 @@ ${project.groupId}.*;version=${project.version};-split-package:=error + org.apache.log4j.config;resolution:=optional, *;resolution:=optional diff -Nru jboss-logging-3.3.0/src/main/java/org/jboss/logging/JBossLogManagerLogger.java jboss-logging-3.3.1/src/main/java/org/jboss/logging/JBossLogManagerLogger.java --- jboss-logging-3.3.0/src/main/java/org/jboss/logging/JBossLogManagerLogger.java 2015-05-28 16:49:04.000000000 +0000 +++ jboss-logging-3.3.1/src/main/java/org/jboss/logging/JBossLogManagerLogger.java 2017-03-15 20:21:35.000000000 +0000 @@ -55,13 +55,23 @@ } private static java.util.logging.Level translate(final Level level) { - if (level != null) switch (level) { - case FATAL: return org.jboss.logmanager.Level.FATAL; - case ERROR: return org.jboss.logmanager.Level.ERROR; - case WARN: return org.jboss.logmanager.Level.WARN; - case INFO: return org.jboss.logmanager.Level.INFO; - case DEBUG: return org.jboss.logmanager.Level.DEBUG; - case TRACE: return org.jboss.logmanager.Level.TRACE; + if (level == Level.TRACE) { + return org.jboss.logmanager.Level.TRACE; + } else if (level == Level.DEBUG) { + return org.jboss.logmanager.Level.DEBUG; + } + return infoOrHigher(level); + } + + private static java.util.logging.Level infoOrHigher(final Level level) { + if (level == Level.INFO) { + return org.jboss.logmanager.Level.INFO; + } else if (level == Level.WARN) { + return org.jboss.logmanager.Level.WARN; + } else if (level == Level.ERROR) { + return org.jboss.logmanager.Level.ERROR; + } else if (level == Level.FATAL) { + return org.jboss.logmanager.Level.FATAL; } return org.jboss.logmanager.Level.ALL; } diff -Nru jboss-logging-3.3.0/src/main/java/org/jboss/logging/JDKLogger.java jboss-logging-3.3.1/src/main/java/org/jboss/logging/JDKLogger.java --- jboss-logging-3.3.0/src/main/java/org/jboss/logging/JDKLogger.java 2015-05-28 16:49:04.000000000 +0000 +++ jboss-logging-3.3.1/src/main/java/org/jboss/logging/JDKLogger.java 2017-03-15 20:21:35.000000000 +0000 @@ -66,13 +66,23 @@ } private static java.util.logging.Level translate(final Level level) { - if (level != null) switch (level) { - case FATAL: return JDKLevel.FATAL; - case ERROR: return JDKLevel.ERROR; - case WARN: return JDKLevel.WARN; - case INFO: return JDKLevel.INFO; - case DEBUG: return JDKLevel.DEBUG; - case TRACE: return JDKLevel.TRACE; + if (level == Level.TRACE) { + return JDKLevel.TRACE; + } else if (level == Level.DEBUG) { + return JDKLevel.DEBUG; + } + return infoOrHigher(level); + } + + private static java.util.logging.Level infoOrHigher(final Level level) { + if (level == Level.INFO) { + return JDKLevel.INFO; + } else if (level == Level.WARN) { + return JDKLevel.WARN; + } else if (level == Level.ERROR) { + return JDKLevel.ERROR; + } else if (level == Level.FATAL) { + return JDKLevel.FATAL; } return JDKLevel.ALL; } diff -Nru jboss-logging-3.3.0/src/main/java/org/jboss/logging/Log4j2Logger.java jboss-logging-3.3.1/src/main/java/org/jboss/logging/Log4j2Logger.java --- jboss-logging-3.3.0/src/main/java/org/jboss/logging/Log4j2Logger.java 2015-05-28 16:49:04.000000000 +0000 +++ jboss-logging-3.3.1/src/main/java/org/jboss/logging/Log4j2Logger.java 2017-03-15 20:21:35.000000000 +0000 @@ -69,15 +69,23 @@ } private static org.apache.logging.log4j.Level translate(final Level level) { - if (level != null) { - switch (level) { - case FATAL: return org.apache.logging.log4j.Level.FATAL; - case ERROR: return org.apache.logging.log4j.Level.ERROR; - case WARN: return org.apache.logging.log4j.Level.WARN; - case INFO: return org.apache.logging.log4j.Level.INFO; - case DEBUG: return org.apache.logging.log4j.Level.DEBUG; - case TRACE: return org.apache.logging.log4j.Level.TRACE; - } + if (level == Level.TRACE) { + return org.apache.logging.log4j.Level.TRACE; + } else if (level == Level.DEBUG) { + return org.apache.logging.log4j.Level.DEBUG; + } + return infoOrHigher(level); + } + + private static org.apache.logging.log4j.Level infoOrHigher(final Level level) { + if (level == Level.INFO) { + return org.apache.logging.log4j.Level.INFO; + } else if (level == Level.WARN) { + return org.apache.logging.log4j.Level.WARN; + } else if (level == Level.ERROR) { + return org.apache.logging.log4j.Level.ERROR; + } else if (level == Level.FATAL) { + return org.apache.logging.log4j.Level.FATAL; } return org.apache.logging.log4j.Level.ALL; } diff -Nru jboss-logging-3.3.0/src/main/java/org/jboss/logging/Log4jLogger.java jboss-logging-3.3.1/src/main/java/org/jboss/logging/Log4jLogger.java --- jboss-logging-3.3.0/src/main/java/org/jboss/logging/Log4jLogger.java 2015-05-28 16:49:04.000000000 +0000 +++ jboss-logging-3.3.1/src/main/java/org/jboss/logging/Log4jLogger.java 2017-03-15 20:21:35.000000000 +0000 @@ -51,13 +51,23 @@ } private static org.apache.log4j.Level translate(final Level level) { - if (level != null) switch (level) { - case FATAL: return org.apache.log4j.Level.FATAL; - case ERROR: return org.apache.log4j.Level.ERROR; - case WARN: return org.apache.log4j.Level.WARN; - case INFO: return org.apache.log4j.Level.INFO; - case DEBUG: return org.apache.log4j.Level.DEBUG; - case TRACE: return org.apache.log4j.Level.TRACE; + if (level == Level.TRACE) { + return org.apache.log4j.Level.TRACE; + } else if (level == Level.DEBUG) { + return org.apache.log4j.Level.DEBUG; + } + return infoOrHigher(level); + } + + private static org.apache.log4j.Level infoOrHigher(final Level level) { + if (level == Level.INFO) { + return org.apache.log4j.Level.INFO; + } else if (level == Level.WARN) { + return org.apache.log4j.Level.WARN; + } else if (level == Level.ERROR) { + return org.apache.log4j.Level.ERROR; + } else if (level == Level.FATAL) { + return org.apache.log4j.Level.FATAL; } return org.apache.log4j.Level.ALL; } diff -Nru jboss-logging-3.3.0/src/main/java/org/jboss/logging/Logger.java jboss-logging-3.3.1/src/main/java/org/jboss/logging/Logger.java --- jboss-logging-3.3.0/src/main/java/org/jboss/logging/Logger.java 2015-05-28 16:49:04.000000000 +0000 +++ jboss-logging-3.3.1/src/main/java/org/jboss/logging/Logger.java 2017-03-15 20:21:35.000000000 +0000 @@ -2513,7 +2513,7 @@ * @return the typed logger */ public static T getMessageLogger(Class type, String category) { - return getMessageLogger(type, category, Locale.getDefault()); + return getMessageLogger(type, category, LoggingLocale.getLocale()); } /** diff -Nru jboss-logging-3.3.0/src/main/java/org/jboss/logging/LoggingLocale.java jboss-logging-3.3.1/src/main/java/org/jboss/logging/LoggingLocale.java --- jboss-logging-3.3.0/src/main/java/org/jboss/logging/LoggingLocale.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-3.3.1/src/main/java/org/jboss/logging/LoggingLocale.java 2017-03-15 20:21:35.000000000 +0000 @@ -0,0 +1,177 @@ +/* + * JBoss, Home of Professional Open Source. + * + * Copyright 2017 Red Hat, Inc. + * + * Licensed 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.jboss.logging; + +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.Locale; + +/** + * A simple utility to resolve the default locale to use for internationalized loggers and message bundles. + * + * @author James R. Perkins + */ +@SuppressWarnings("SameParameterValue") +class LoggingLocale { + + private static final Locale LOCALE = getDefaultLocale(); + + /** + * Attempts to create a {@link Locale} based on the {@code org.jboss.logging.locale} system property. If the value + * is not defined the {@linkplain Locale#getDefault() default locale} will be used. + *

+ * The value should be in the BCP 47 format. + *

+ *

+ * Note: Currently this uses a custom parser to attempt to parse the BCP 47 format. This will be + * changed to use the {@code Locale.forLanguageTag()} once a move to JDK 7. Currently only the language, region and + * variant are used to construct the locale. + *

+ * + * @return the locale created or the default locale + */ + static Locale getLocale() { + return LOCALE; + } + + private static Locale getDefaultLocale() { + final String bcp47Tag = AccessController.doPrivileged(new PrivilegedAction() { + @Override + public String run() { + return System.getProperty("org.jboss.logging.locale", ""); + } + }); + if (bcp47Tag.trim().isEmpty()) { + return Locale.getDefault(); + } + // When we upgrade to Java 7 we can use the Locale.forLanguageTag(locale) which will reliably parse the + // the value. For now we have to attempt to parse it the best we can. + return forLanguageTag(bcp47Tag); + } + + private static Locale forLanguageTag(final String locale) { + // First check known locales + if ("en-CA".equalsIgnoreCase(locale)) { + return Locale.CANADA; + } else if ("fr-CA".equalsIgnoreCase(locale)) { + return Locale.CANADA_FRENCH; + } else if ("zh".equalsIgnoreCase(locale)) { + return Locale.CHINESE; + } else if ("en".equalsIgnoreCase(locale)) { + return Locale.ENGLISH; + } else if ("fr-FR".equalsIgnoreCase(locale)) { + return Locale.FRANCE; + } else if ("fr".equalsIgnoreCase(locale)) { + return Locale.FRENCH; + } else if ("de".equalsIgnoreCase(locale)) { + return Locale.GERMAN; + } else if ("de-DE".equalsIgnoreCase(locale)) { + return Locale.GERMANY; + } else if ("it".equalsIgnoreCase(locale)) { + return Locale.ITALIAN; + } else if ("it-IT".equalsIgnoreCase(locale)) { + return Locale.ITALY; + } else if ("ja-JP".equalsIgnoreCase(locale)) { + return Locale.JAPAN; + } else if ("ja".equalsIgnoreCase(locale)) { + return Locale.JAPANESE; + } else if ("ko-KR".equalsIgnoreCase(locale)) { + return Locale.KOREA; + } else if ("ko".equalsIgnoreCase(locale)) { + return Locale.KOREAN; + } else if ("zh-CN".equalsIgnoreCase(locale)) { + return Locale.SIMPLIFIED_CHINESE; + } else if ("zh-TW".equalsIgnoreCase(locale)) { + return Locale.TRADITIONAL_CHINESE; + } else if ("en-UK".equalsIgnoreCase(locale)) { + return Locale.UK; + } else if ("en-US".equalsIgnoreCase(locale)) { + return Locale.US; + } + + // Split the string into parts and attempt + final String[] parts = locale.split("-"); + final int len = parts.length; + int index = 0; + int count = 0; + final String language = parts[index++]; + String region = ""; // country + String variant = ""; + // The next 3 sections may be extended languages, we're just going to ignore them + while (index < len) { + if (count++ == 2 || !isAlpha(parts[index], 3, 3)) { + break; + } + index++; + } + // Check for a script, we'll skip it however a script is not supported until Java 7 + if (index != len && isAlpha(parts[index], 4, 4)) { + index++; + } + // Next should be the region, 3 digit is allowed but may not work with Java 6 + if (index != len && (isAlpha(parts[index], 2, 2) || isNumeric(parts[index], 3, 3))) { + region = parts[index++]; + } + // Next should be the variant and we will just use the first one found, all other parts will be ignored + if (index != len && (isAlphaOrNumeric(parts[index], 5, 8))) { + variant = parts[index]; + } + return new Locale(language, region, variant); + } + + private static boolean isAlpha(final String value, final int minLen, final int maxLen) { + final int len = value.length(); + if (len < minLen || len > maxLen) { + return false; + } + for (int i = 0; i < len; i++) { + if (!Character.isLetter(value.charAt(i))) { + return false; + } + } + return true; + } + + private static boolean isNumeric(final String value, final int minLen, final int maxLen) { + final int len = value.length(); + if (len < minLen || len > maxLen) { + return false; + } + for (int i = 0; i < len; i++) { + if (!Character.isDigit(value.charAt(i))) { + return false; + } + } + return true; + } + + private static boolean isAlphaOrNumeric(final String value, final int minLen, final int maxLen) { + + final int len = value.length(); + if (len < minLen || len > maxLen) { + return false; + } + for (int i = 0; i < len; i++) { + if (!Character.isLetterOrDigit(value.charAt(i))) { + return false; + } + } + return true; + } +} diff -Nru jboss-logging-3.3.0/src/main/java/org/jboss/logging/Messages.java jboss-logging-3.3.1/src/main/java/org/jboss/logging/Messages.java --- jboss-logging-3.3.0/src/main/java/org/jboss/logging/Messages.java 2015-05-28 16:49:04.000000000 +0000 +++ jboss-logging-3.3.1/src/main/java/org/jboss/logging/Messages.java 2017-03-15 20:21:35.000000000 +0000 @@ -43,7 +43,7 @@ * @return the bundle */ public static T getBundle(Class type) { - return getBundle(type, Locale.getDefault()); + return getBundle(type, LoggingLocale.getLocale()); } /** diff -Nru jboss-logging-3.3.0/src/main/java/org/jboss/logging/Slf4jLogger.java jboss-logging-3.3.1/src/main/java/org/jboss/logging/Slf4jLogger.java --- jboss-logging-3.3.0/src/main/java/org/jboss/logging/Slf4jLogger.java 2015-05-28 16:49:04.000000000 +0000 +++ jboss-logging-3.3.1/src/main/java/org/jboss/logging/Slf4jLogger.java 2017-03-15 20:21:35.000000000 +0000 @@ -32,13 +32,21 @@ } public boolean isEnabled(final Level level) { - if (level != null) switch (level) { - case FATAL: return logger.isErrorEnabled(); - case ERROR: return logger.isErrorEnabled(); - case WARN: return logger.isWarnEnabled(); - case INFO: return logger.isInfoEnabled(); - case DEBUG: return logger.isDebugEnabled(); - case TRACE: return logger.isTraceEnabled(); + if (level == Level.TRACE) { + return logger.isTraceEnabled(); + } else if (level == Level.DEBUG) { + return logger.isDebugEnabled(); + } + return infoOrHigherEnabled(level); + } + + private boolean infoOrHigherEnabled(final Level level) { + if (level == Level.INFO) { + return logger.isInfoEnabled(); + } else if (level == Level.WARN) { + return logger.isWarnEnabled(); + } else if (level == Level.ERROR || level == Level.FATAL) { + return logger.isErrorEnabled(); } return true; } @@ -46,23 +54,16 @@ protected void doLog(final Level level, final String loggerClassName, final Object message, final Object[] parameters, final Throwable thrown) { if (isEnabled(level)) try { final String text = parameters == null || parameters.length == 0 ? String.valueOf(message) : MessageFormat.format(String.valueOf(message), parameters); - switch (level) { - case FATAL: - case ERROR: - logger.error(text, thrown); - return; - case WARN: - logger.warn(text, thrown); - return; - case INFO: - logger.info(text, thrown); - return; - case DEBUG: - logger.debug(text, thrown); - return; - case TRACE: - logger.trace(text, thrown); - return; + if (level == Level.INFO) { + logger.info(text, thrown); + } else if (level == Level.WARN) { + logger.warn(text, thrown); + } else if (level == Level.ERROR || level == Level.FATAL) { + logger.error(text, thrown); + } else if (level == Level.DEBUG) { + logger.debug(text, thrown); + } else if (level == Level.TRACE) { + logger.debug(text, thrown); } } catch (Throwable ignored) {} } @@ -70,23 +71,16 @@ protected void doLogf(final Level level, final String loggerClassName, final String format, final Object[] parameters, final Throwable thrown) { if (isEnabled(level)) try { final String text = parameters == null ? String.format(format) : String.format(format, parameters); - switch (level) { - case FATAL: - case ERROR: - logger.error(text, thrown); - return; - case WARN: - logger.warn(text, thrown); - return; - case INFO: - logger.info(text, thrown); - return; - case DEBUG: - logger.debug(text, thrown); - return; - case TRACE: - logger.trace(text, thrown); - return; + if (level == Level.INFO) { + logger.info(text, thrown); + } else if (level == Level.WARN) { + logger.warn(text, thrown); + } else if (level == Level.ERROR || level == Level.FATAL) { + logger.error(text, thrown); + } else if (level == Level.DEBUG) { + logger.debug(text, thrown); + } else if (level == Level.TRACE) { + logger.debug(text, thrown); } } catch (Throwable ignored) {} }