[Git][java-team/jboss-logging][upstream] New upstream version 3.4.1
Markus Koschany
gitlab at salsa.debian.org
Sun Aug 11 23:49:28 BST 2019
Markus Koschany pushed to branch upstream at Debian Java Maintainers / jboss-logging
Commits:
694195ed by Markus Koschany at 2019-08-11T22:45:18Z
New upstream version 3.4.1
- - - - -
7 changed files:
- pom.xml
- src/main/java/org/jboss/logging/Logger.java
- src/main/java/org/jboss/logging/LoggerProviders.java
- src/main/java/org/jboss/logging/LoggingLocale.java
- src/main/java/org/jboss/logging/Messages.java
- + src/main/java/org/jboss/logging/SecurityActions.java
- src/main/java/org/jboss/logging/Slf4jLoggerProvider.java
Changes:
=====================================
pom.xml
=====================================
@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
- <version>3.4.0.Final</version>
+ <version>3.4.1.Final</version>
<packaging>jar</packaging>
<name>JBoss Logging 3</name>
<url>http://www.jboss.org</url>
=====================================
src/main/java/org/jboss/logging/Logger.java
=====================================
@@ -2526,54 +2526,60 @@ public abstract class Logger implements Serializable, BasicLogger {
* @return the typed logger
*/
public static <T> T getMessageLogger(final Class<T> type, final String category, final Locale locale) {
+ if (System.getSecurityManager() == null)
+ return doGetMessageLogger(type, category, locale);
return doPrivileged(new PrivilegedAction<T>() {
public T run() {
- String language = locale.getLanguage();
- String country = locale.getCountry();
- String variant = locale.getVariant();
-
- Class<? extends T> loggerClass = null;
- final ClassLoader classLoader = type.getClassLoader();
- final String typeName = type.getName();
- if (variant != null && variant.length() > 0) try {
- loggerClass = Class.forName(join(typeName, "$logger", language, country, variant), true, classLoader).asSubclass(type);
- } catch (ClassNotFoundException e) {
- // ignore
- }
- if (loggerClass == null && country != null && country.length() > 0) try {
- loggerClass = Class.forName(join(typeName, "$logger", language, country, null), true, classLoader).asSubclass(type);
- } catch (ClassNotFoundException e) {
- // ignore
- }
- if (loggerClass == null && language != null && language.length() > 0) try {
- loggerClass = Class.forName(join(typeName, "$logger", language, null, null), true, classLoader).asSubclass(type);
- } catch (ClassNotFoundException e) {
- // ignore
- }
- if (loggerClass == null) try {
- loggerClass = Class.forName(join(typeName, "$logger", null, null, null), true, classLoader).asSubclass(type);
- } catch (ClassNotFoundException e) {
- throw new IllegalArgumentException("Invalid logger " + type + " (implementation not found in " + classLoader + ")");
- }
- final Constructor<? extends T> constructor;
- try {
- constructor = loggerClass.getConstructor(Logger.class);
- } catch (NoSuchMethodException e) {
- throw new IllegalArgumentException("Logger implementation " + loggerClass + " has no matching constructor");
- }
- try {
- return constructor.newInstance(Logger.getLogger(category));
- } catch (InstantiationException e) {
- throw new IllegalArgumentException("Logger implementation " + loggerClass + " could not be instantiated", e);
- } catch (IllegalAccessException e) {
- throw new IllegalArgumentException("Logger implementation " + loggerClass + " could not be instantiated", e);
- } catch (InvocationTargetException e) {
- throw new IllegalArgumentException("Logger implementation " + loggerClass + " could not be instantiated", e.getCause());
- }
+ return doGetMessageLogger(type, category, locale);
}
});
}
+ private static <T> T doGetMessageLogger(final Class<T> type, final String category, final Locale locale) {
+ String language = locale.getLanguage();
+ String country = locale.getCountry();
+ String variant = locale.getVariant();
+
+ Class<? extends T> loggerClass = null;
+ final ClassLoader classLoader = type.getClassLoader();
+ final String typeName = type.getName();
+ if (variant != null && variant.length() > 0) try {
+ loggerClass = Class.forName(join(typeName, "$logger", language, country, variant), true, classLoader).asSubclass(type);
+ } catch (ClassNotFoundException e) {
+ // ignore
+ }
+ if (loggerClass == null && country != null && country.length() > 0) try {
+ loggerClass = Class.forName(join(typeName, "$logger", language, country, null), true, classLoader).asSubclass(type);
+ } catch (ClassNotFoundException e) {
+ // ignore
+ }
+ if (loggerClass == null && language != null && language.length() > 0) try {
+ loggerClass = Class.forName(join(typeName, "$logger", language, null, null), true, classLoader).asSubclass(type);
+ } catch (ClassNotFoundException e) {
+ // ignore
+ }
+ if (loggerClass == null) try {
+ loggerClass = Class.forName(join(typeName, "$logger", null, null, null), true, classLoader).asSubclass(type);
+ } catch (ClassNotFoundException e) {
+ throw new IllegalArgumentException("Invalid logger " + type + " (implementation not found in " + classLoader + ")");
+ }
+ final Constructor<? extends T> constructor;
+ try {
+ constructor = loggerClass.getConstructor(Logger.class);
+ } catch (NoSuchMethodException e) {
+ throw new IllegalArgumentException("Logger implementation " + loggerClass + " has no matching constructor");
+ }
+ try {
+ return constructor.newInstance(Logger.getLogger(category));
+ } catch (InstantiationException e) {
+ throw new IllegalArgumentException("Logger implementation " + loggerClass + " could not be instantiated", e);
+ } catch (IllegalAccessException e) {
+ throw new IllegalArgumentException("Logger implementation " + loggerClass + " could not be instantiated", e);
+ } catch (InvocationTargetException e) {
+ throw new IllegalArgumentException("Logger implementation " + loggerClass + " could not be instantiated", e.getCause());
+ }
+ }
+
private static String join(String interfaceName, String a, String b, String c, String d) {
final StringBuilder build = new StringBuilder();
build.append(interfaceName).append('_').append(a);
@@ -2591,4 +2597,4 @@ public abstract class Logger implements Serializable, BasicLogger {
}
return build.toString();
}
-}
\ No newline at end of file
+}
=====================================
src/main/java/org/jboss/logging/LoggerProviders.java
=====================================
@@ -18,8 +18,6 @@
package org.jboss.logging;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
import java.util.Iterator;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
@@ -41,11 +39,7 @@ final class LoggerProviders {
final ClassLoader cl = LoggerProviders.class.getClassLoader();
try {
// Check the system property
- final String loggerProvider = AccessController.doPrivileged(new PrivilegedAction<String>() {
- public String run() {
- return System.getProperty(LOGGING_PROVIDER_KEY);
- }
- });
+ final String loggerProvider = SecurityActions.getSystemProperty(LOGGING_PROVIDER_KEY);
if (loggerProvider != null) {
if ("jboss".equalsIgnoreCase(loggerProvider)) {
return tryJBossLogManager(cl, "system property");
=====================================
src/main/java/org/jboss/logging/LoggingLocale.java
=====================================
@@ -18,8 +18,6 @@
package org.jboss.logging;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
import java.util.Locale;
/**
@@ -51,12 +49,7 @@ class LoggingLocale {
}
private static Locale getDefaultLocale() {
- final String bcp47Tag = AccessController.doPrivileged(new PrivilegedAction<String>() {
- @Override
- public String run() {
- return System.getProperty("org.jboss.logging.locale", "");
- }
- });
+ final String bcp47Tag = SecurityActions.getSystemProperty("org.jboss.logging.locale", "");
if (bcp47Tag.trim().isEmpty()) {
return Locale.getDefault();
}
=====================================
src/main/java/org/jboss/logging/Messages.java
=====================================
@@ -55,48 +55,55 @@ public final class Messages {
* @return the bundle
*/
public static <T> T getBundle(final Class<T> type, final Locale locale) {
+ if (System.getSecurityManager() == null) {
+ return doGetBundle(type, locale);
+ }
return doPrivileged(new PrivilegedAction<T>() {
public T run() {
- String language = locale.getLanguage();
- String country = locale.getCountry();
- String variant = locale.getVariant();
-
- Class<? extends T> bundleClass = null;
- if (variant != null && variant.length() > 0) try {
- bundleClass = Class.forName(join(type.getName(), "$bundle", language, country, variant), true, type.getClassLoader()).asSubclass(type);
- } catch (ClassNotFoundException e) {
- // ignore
- }
- if (bundleClass == null && country != null && country.length() > 0) try {
- bundleClass = Class.forName(join(type.getName(), "$bundle", language, country, null), true, type.getClassLoader()).asSubclass(type);
- } catch (ClassNotFoundException e) {
- // ignore
- }
- if (bundleClass == null && language != null && language.length() > 0) try {
- bundleClass = Class.forName(join(type.getName(), "$bundle", language, null, null), true, type.getClassLoader()).asSubclass(type);
- } catch (ClassNotFoundException e) {
- // ignore
- }
- if (bundleClass == null) try {
- bundleClass = Class.forName(join(type.getName(), "$bundle", null, null, null), true, type.getClassLoader()).asSubclass(type);
- } catch (ClassNotFoundException e) {
- throw new IllegalArgumentException("Invalid bundle " + type + " (implementation not found)");
- }
- final Field field;
- try {
- field = bundleClass.getField("INSTANCE");
- } catch (NoSuchFieldException e) {
- throw new IllegalArgumentException("Bundle implementation " + bundleClass + " has no instance field");
- }
- try {
- return type.cast(field.get(null));
- } catch (IllegalAccessException e) {
- throw new IllegalArgumentException("Bundle implementation " + bundleClass + " could not be instantiated", e);
- }
+ return doGetBundle(type, locale);
}
});
}
+ private static <T> T doGetBundle(final Class<T> type, final Locale locale) {
+ String language = locale.getLanguage();
+ String country = locale.getCountry();
+ String variant = locale.getVariant();
+
+ Class<? extends T> bundleClass = null;
+ if (variant != null && variant.length() > 0) try {
+ bundleClass = Class.forName(join(type.getName(), "$bundle", language, country, variant), true, type.getClassLoader()).asSubclass(type);
+ } catch (ClassNotFoundException e) {
+ // ignore
+ }
+ if (bundleClass == null && country != null && country.length() > 0) try {
+ bundleClass = Class.forName(join(type.getName(), "$bundle", language, country, null), true, type.getClassLoader()).asSubclass(type);
+ } catch (ClassNotFoundException e) {
+ // ignore
+ }
+ if (bundleClass == null && language != null && language.length() > 0) try {
+ bundleClass = Class.forName(join(type.getName(), "$bundle", language, null, null), true, type.getClassLoader()).asSubclass(type);
+ } catch (ClassNotFoundException e) {
+ // ignore
+ }
+ if (bundleClass == null) try {
+ bundleClass = Class.forName(join(type.getName(), "$bundle", null, null, null), true, type.getClassLoader()).asSubclass(type);
+ } catch (ClassNotFoundException e) {
+ throw new IllegalArgumentException("Invalid bundle " + type + " (implementation not found)");
+ }
+ final Field field;
+ try {
+ field = bundleClass.getField("INSTANCE");
+ } catch (NoSuchFieldException e) {
+ throw new IllegalArgumentException("Bundle implementation " + bundleClass + " has no instance field");
+ }
+ try {
+ return type.cast(field.get(null));
+ } catch (IllegalAccessException e) {
+ throw new IllegalArgumentException("Bundle implementation " + bundleClass + " could not be instantiated", e);
+ }
+ }
+
private static String join(String interfaceName, String a, String b, String c, String d) {
final StringBuilder build = new StringBuilder();
build.append(interfaceName).append('_').append(a);
=====================================
src/main/java/org/jboss/logging/SecurityActions.java
=====================================
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * Copyright 2019 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;
+
+/**
+ * @author <a href="mailto:jperkins at redhat.com">James R. Perkins</a>
+ */
+ at SuppressWarnings("SameParameterValue")
+class SecurityActions {
+
+ static String getSystemProperty(final String key) {
+ if (System.getSecurityManager() == null) {
+ return System.getProperty(key);
+ }
+ return AccessController.doPrivileged(new PrivilegedAction<String>() {
+ @Override
+ public String run() {
+ return System.getProperty(key);
+ }
+ });
+ }
+
+ static String getSystemProperty(final String key, final String dft) {
+ if (System.getSecurityManager() == null) {
+ return System.getProperty(key, dft);
+ }
+ return AccessController.doPrivileged(new PrivilegedAction<String>() {
+ @Override
+ public String run() {
+ return System.getProperty(key, dft);
+ }
+ });
+ }
+}
=====================================
src/main/java/org/jboss/logging/Slf4jLoggerProvider.java
=====================================
@@ -30,9 +30,8 @@ final class Slf4jLoggerProvider extends AbstractLoggerProvider implements Logger
public Logger getLogger(final String name) {
org.slf4j.Logger l = LoggerFactory.getLogger(name);
- try {
+ if (l instanceof LocationAwareLogger) {
return new Slf4jLocationAwareLogger(name, (LocationAwareLogger) l);
- } catch (Throwable ignored) {
}
return new Slf4jLogger(name, l);
}
View it on GitLab: https://salsa.debian.org/java-team/jboss-logging/commit/694195ed35865cb5c28afa08b043d331093f2ab6
--
View it on GitLab: https://salsa.debian.org/java-team/jboss-logging/commit/694195ed35865cb5c28afa08b043d331093f2ab6
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20190811/56738d85/attachment.html>
More information about the pkg-java-commits
mailing list