[Git][java-team/logback][master] 4 commits: New upstream version 1.2.11
Tony Mancill (@tmancill)
gitlab at salsa.debian.org
Wed Mar 23 03:55:30 GMT 2022
Tony Mancill pushed to branch master at Debian Java Maintainers / logback
Commits:
f279610d by tony mancill at 2022-03-22T20:34:27-07:00
New upstream version 1.2.11
- - - - -
affb01d5 by tony mancill at 2022-03-22T20:34:31-07:00
Update upstream source from tag 'upstream/1.2.11'
Update to upstream version '1.2.11'
with Debian dir 30e229abaff425561e2244f535bb8b8d199cb893
- - - - -
77eba909 by tony mancill at 2022-03-22T20:36:03-07:00
Freshen years in debian/copyright
- - - - -
b0043479 by tony mancill at 2022-03-22T20:44:56-07:00
Prepare changelog for upload to unstable
- - - - -
25 changed files:
- debian/changelog
- debian/copyright
- logback-access/pom.xml
- logback-classic/pom.xml
- logback-classic/src/main/java/ch/qos/logback/classic/joran/action/InsertFromJNDIAction.java
- logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextJNDISelector.java
- logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/ContextDetachingSCL.java
- logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxy.java
- logback-classic/src/test/java/ch/qos/logback/classic/pattern/ThrowableProxyConverterTest.java
- logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextDetachingSCLTest.java
- logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextJNDISelectorTest.java
- logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableProxyTest.java
- logback-core/pom.xml
- logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
- logback-core/src/main/java/ch/qos/logback/core/util/JNDIUtil.java
- logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java
- logback-classic/src/test/java/ch/qos/logback/classic/util/MockInitialContext.java → logback-core/src/test/java/ch/qos/logback/core/testUtil/MockInitialContext.java
- logback-classic/src/test/java/ch/qos/logback/classic/util/MockInitialContextFactory.java → logback-core/src/test/java/ch/qos/logback/core/testUtil/MockInitialContextFactory.java
- + logback-core/src/test/java/ch/qos/logback/core/testUtil/VersionUtil.java
- + logback-core/src/test/java/ch/qos/logback/core/testUtil/VersionUtilTest.java
- logback-core/src/test/java/ch/qos/logback/core/util/CoreTestConstants.java
- logback-core/src/test/java/ch/qos/logback/core/util/JNDIUtilTest.java
- logback-examples/pom.xml
- logback-site/pom.xml
- pom.xml
Changes:
=====================================
debian/changelog
=====================================
@@ -1,3 +1,12 @@
+logback (1:1.2.11-1) unstable; urgency=medium
+
+ * New upstream version 1.2.11
+ - Backported fix for StackOverflowError (LOGBACK-1027)
+ - Fixed incorrect String cast in JNDIUtil (LOGBACK-1604)
+ - Empty username in SMTPAppenderBase treated as null. (LOGBACK-1594)
+
+ -- tony mancill <tmancill at debian.org> Tue, 22 Mar 2022 20:36:14 -0700
+
logback (1:1.2.10-1) unstable; urgency=medium
* New upstream version 1.2.10
=====================================
debian/copyright
=====================================
@@ -10,7 +10,7 @@ Files-Excluded: *.jar
*/jquery-min.js
Files: *
-Copyright: 2000-2021, QOS.ch
+Copyright: 2000-2022, QOS.ch
License: LGPL-2.1 or EPL-1.0
Comment:
This program and the accompanying materials are dual-licensed under
@@ -24,8 +24,8 @@ Comment:
Files: debian/*
Copyright: 2008-2011, Damien Raude-Morvan <drazzib at debian.org>
- 2014-2021, Emmanuel Bourg <ebourg at apache.org>
- 2017-2021 tony mancill <tmancill at debian.org>
+ 2014-2022, Emmanuel Bourg <ebourg at apache.org>
+ 2017-2022, tony mancill <tmancill at debian.org>
License: LGPL-2.1 or BSD-X11
License: BSD-X11
=====================================
logback-access/pom.xml
=====================================
@@ -8,7 +8,7 @@
<parent>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-parent</artifactId>
- <version>1.2.10</version>
+ <version>1.2.11</version>
</parent>
<artifactId>logback-access</artifactId>
@@ -91,7 +91,6 @@
<id>bundle-test-jar</id>
<phase>package</phase>
<goals>
- <goal>jar</goal>
<goal>test-jar</goal>
</goals>
</execution>
=====================================
logback-classic/pom.xml
=====================================
@@ -8,7 +8,7 @@
<parent>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-parent</artifactId>
- <version>1.2.10</version>
+ <version>1.2.11</version>
</parent>
<artifactId>logback-classic</artifactId>
@@ -164,7 +164,6 @@
<id>bundle-test-jar</id>
<phase>package</phase>
<goals>
- <goal>jar</goal>
<goal>test-jar</goal>
</goals>
</execution>
=====================================
logback-classic/src/main/java/ch/qos/logback/classic/joran/action/InsertFromJNDIAction.java
=====================================
@@ -65,7 +65,7 @@ public class InsertFromJNDIAction extends Action {
try {
Context ctx = JNDIUtil.getInitialContext();
- envEntryValue = JNDIUtil.lookup(ctx, envEntryName);
+ envEntryValue = JNDIUtil.lookupString(ctx, envEntryName);
if (OptionHelper.isEmpty(envEntryValue)) {
addError("[" + envEntryName + "] has null or empty value");
} else {
=====================================
logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextJNDISelector.java
=====================================
@@ -84,7 +84,7 @@ public class ContextJNDISelector implements ContextSelector {
// We first try to find the name of our
// environment's LoggerContext
ctx = JNDIUtil.getInitialContext();
- contextName = (String) JNDIUtil.lookup(ctx, JNDI_CONTEXT_NAME);
+ contextName = (String) JNDIUtil.lookupString(ctx, JNDI_CONTEXT_NAME);
} catch (NamingException ne) {
// We can't log here
}
@@ -127,7 +127,7 @@ public class ContextJNDISelector implements ContextSelector {
String jndiEntryForConfigResource = null;
try {
- jndiEntryForConfigResource = JNDIUtil.lookup(ctx, JNDI_CONFIGURATION_RESOURCE);
+ jndiEntryForConfigResource = JNDIUtil.lookupString(ctx, JNDI_CONFIGURATION_RESOURCE);
} catch (NamingException ne) {
}
// Do we have a dedicated configuration file?
=====================================
logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/ContextDetachingSCL.java
=====================================
@@ -40,7 +40,7 @@ public class ContextDetachingSCL implements ServletContextListener {
try {
Context ctx = JNDIUtil.getInitialContext();
- loggerContextName = (String) JNDIUtil.lookup(ctx, JNDI_CONTEXT_NAME);
+ loggerContextName = (String) JNDIUtil.lookupString(ctx, JNDI_CONTEXT_NAME);
} catch (NamingException ne) {
}
=====================================
logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxy.java
=====================================
@@ -17,141 +17,196 @@ import ch.qos.logback.core.CoreConstants;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Set;
public class ThrowableProxy implements IThrowableProxy {
- private Throwable throwable;
- private String className;
- private String message;
- // package-private because of ThrowableProxyUtil
- StackTraceElementProxy[] stackTraceElementProxyArray;
- // package-private because of ThrowableProxyUtil
- int commonFrames;
- private ThrowableProxy cause;
- private ThrowableProxy[] suppressed = NO_SUPPRESSED;
-
- private transient PackagingDataCalculator packagingDataCalculator;
- private boolean calculatedPackageData = false;
-
- private static final Method GET_SUPPRESSED_METHOD;
-
- static {
- Method method = null;
- try {
- method = Throwable.class.getMethod("getSuppressed");
- } catch (NoSuchMethodException e) {
- // ignore, will get thrown in Java < 7
- }
- GET_SUPPRESSED_METHOD = method;
- }
-
- private static final ThrowableProxy[] NO_SUPPRESSED = new ThrowableProxy[0];
-
- public ThrowableProxy(Throwable throwable) {
-
- this.throwable = throwable;
- this.className = throwable.getClass().getName();
- this.message = throwable.getMessage();
- this.stackTraceElementProxyArray = ThrowableProxyUtil.steArrayToStepArray(throwable.getStackTrace());
-
- Throwable nested = throwable.getCause();
-
- if (nested != null) {
- this.cause = new ThrowableProxy(nested);
- this.cause.commonFrames = ThrowableProxyUtil.findNumberOfCommonFrames(nested.getStackTrace(), stackTraceElementProxyArray);
- }
- if (GET_SUPPRESSED_METHOD != null) {
- // this will only execute on Java 7
- try {
- Object obj = GET_SUPPRESSED_METHOD.invoke(throwable);
- if (obj instanceof Throwable[]) {
- Throwable[] throwableSuppressed = (Throwable[]) obj;
- if (throwableSuppressed.length > 0) {
- suppressed = new ThrowableProxy[throwableSuppressed.length];
- for (int i = 0; i < throwableSuppressed.length; i++) {
- this.suppressed[i] = new ThrowableProxy(throwableSuppressed[i]);
- this.suppressed[i].commonFrames = ThrowableProxyUtil.findNumberOfCommonFrames(throwableSuppressed[i].getStackTrace(),
- stackTraceElementProxyArray);
- }
- }
- }
- } catch (IllegalAccessException e) {
- // ignore
- } catch (InvocationTargetException e) {
- // ignore
- }
- }
-
- }
-
- public Throwable getThrowable() {
- return throwable;
- }
-
- public String getMessage() {
- return message;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ch.qos.logback.classic.spi.IThrowableProxy#getClassName()
- */
- public String getClassName() {
- return className;
- }
-
- public StackTraceElementProxy[] getStackTraceElementProxyArray() {
- return stackTraceElementProxyArray;
- }
-
- public int getCommonFrames() {
- return commonFrames;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see ch.qos.logback.classic.spi.IThrowableProxy#getCause()
- */
- public IThrowableProxy getCause() {
- return cause;
- }
-
- public IThrowableProxy[] getSuppressed() {
- return suppressed;
- }
-
- public PackagingDataCalculator getPackagingDataCalculator() {
- // if original instance (non-deserialized), and packagingDataCalculator
- // is not already initialized, then create an instance.
- // here we assume that (throwable == null) for deserialized instances
- if (throwable != null && packagingDataCalculator == null) {
- packagingDataCalculator = new PackagingDataCalculator();
- }
- return packagingDataCalculator;
- }
-
- public void calculatePackagingData() {
- if (calculatedPackageData) {
- return;
- }
- PackagingDataCalculator pdc = this.getPackagingDataCalculator();
- if (pdc != null) {
- calculatedPackageData = true;
- pdc.calculate(this);
- }
- }
-
- public void fullDump() {
- StringBuilder builder = new StringBuilder();
- for (StackTraceElementProxy step : stackTraceElementProxyArray) {
- String string = step.toString();
- builder.append(CoreConstants.TAB).append(string);
- ThrowableProxyUtil.subjoinPackagingData(builder, step);
- builder.append(CoreConstants.LINE_SEPARATOR);
- }
- System.out.println(builder.toString());
- }
+ static final StackTraceElementProxy[] EMPTY_STEP = new StackTraceElementProxy[0];
+
+ private Throwable throwable;
+ private String className;
+ private String message;
+ // package-private because of ThrowableProxyUtil
+ StackTraceElementProxy[] stackTraceElementProxyArray;
+ // package-private because of ThrowableProxyUtil
+ int commonFrames;
+ private ThrowableProxy cause;
+ private static final ThrowableProxy[] NO_SUPPRESSED = new ThrowableProxy[0];
+ private ThrowableProxy[] suppressed = NO_SUPPRESSED;
+
+ // private final Set<Throwable> alreadyProcessedSet;
+
+ private transient PackagingDataCalculator packagingDataCalculator;
+ private boolean calculatedPackageData = false;
+
+ private boolean circular;
+
+ private static final Method GET_SUPPRESSED_METHOD;
+
+ static {
+ Method method = null;
+ try {
+ method = Throwable.class.getMethod("getSuppressed");
+ } catch (NoSuchMethodException e) {
+ // ignore, will get thrown in Java < 7
+ }
+ GET_SUPPRESSED_METHOD = method;
+ }
+
+ public ThrowableProxy(Throwable throwable) {
+ // use an identity set to detect cycles in the throwable chain
+ this(throwable, Collections.newSetFromMap(new IdentityHashMap<Throwable, Boolean>()));
+ }
+
+ // used for circular exceptions
+ private ThrowableProxy(Throwable circular, boolean isCircular) {
+ this.throwable = circular;
+ this.className = circular.getClass().getName();
+ this.message = circular.getMessage();
+ this.stackTraceElementProxyArray = EMPTY_STEP;
+ this.circular = true;
+ }
+
+ public ThrowableProxy(Throwable throwable, Set<Throwable> alreadyProcessedSet) {
+
+ this.throwable = throwable;
+ this.className = throwable.getClass().getName();
+ this.message = throwable.getMessage();
+ this.stackTraceElementProxyArray = ThrowableProxyUtil.steArrayToStepArray(throwable.getStackTrace());
+ this.circular = false;
+
+ alreadyProcessedSet.add(throwable);
+
+ Throwable nested = throwable.getCause();
+ if (nested != null) {
+ if (alreadyProcessedSet.contains(nested)) {
+ this.cause = new ThrowableProxy(nested, true);
+ } else {
+ this.cause = new ThrowableProxy(nested, alreadyProcessedSet);
+ this.cause.commonFrames = ThrowableProxyUtil.findNumberOfCommonFrames(nested.getStackTrace(),
+ stackTraceElementProxyArray);
+ }
+ }
+
+ if (GET_SUPPRESSED_METHOD != null) {
+ // this will only execute on Java 7
+ Throwable[] throwableSuppressed = extractSupressedThrowables(throwable);
+
+ if (throwableSuppressed.length > 0) {
+ List<ThrowableProxy> suppressedList = new ArrayList<ThrowableProxy>(throwableSuppressed.length);
+ for (Throwable sup : throwableSuppressed) {
+ if (alreadyProcessedSet.contains(sup)) {
+ ThrowableProxy throwableProxy = new ThrowableProxy(sup, true);
+ suppressedList.add(throwableProxy);
+ } else {
+ ThrowableProxy throwableProxy = new ThrowableProxy(sup, alreadyProcessedSet);
+ throwableProxy.commonFrames = ThrowableProxyUtil.findNumberOfCommonFrames(sup.getStackTrace(),
+ stackTraceElementProxyArray);
+ suppressedList.add(throwableProxy);
+ }
+ }
+ this.suppressed = suppressedList.toArray(new ThrowableProxy[suppressedList.size()]);
+ }
+ }
+ }
+
+ private Throwable[] extractSupressedThrowables(Throwable t) {
+ try {
+ Object obj = GET_SUPPRESSED_METHOD.invoke(t);
+ if (obj instanceof Throwable[]) {
+ Throwable[] throwableSuppressed = (Throwable[]) obj;
+ return throwableSuppressed;
+ } else {
+ return null;
+ }
+ } catch (IllegalAccessException e) {
+ // ignore
+ } catch (IllegalArgumentException e) {
+ // ignore
+ } catch (InvocationTargetException e) {
+ // ignore
+ }
+
+ return null;
+
+ }
+
+ public Throwable getThrowable() {
+ return throwable;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ch.qos.logback.classic.spi.IThrowableProxy#getClassName()
+ */
+ public String getClassName() {
+ return className;
+ }
+
+ public StackTraceElementProxy[] getStackTraceElementProxyArray() {
+ return stackTraceElementProxyArray;
+ }
+
+ public boolean isCyclic() {
+ return circular;
+ }
+
+ public int getCommonFrames() {
+ return commonFrames;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ch.qos.logback.classic.spi.IThrowableProxy#getCause()
+ */
+ public IThrowableProxy getCause() {
+ return cause;
+ }
+
+ public IThrowableProxy[] getSuppressed() {
+ return suppressed;
+ }
+
+ public PackagingDataCalculator getPackagingDataCalculator() {
+ // if original instance (non-deserialized), and packagingDataCalculator
+ // is not already initialized, then create an instance.
+ // here we assume that (throwable == null) for deserialized instances
+ if (throwable != null && packagingDataCalculator == null) {
+ packagingDataCalculator = new PackagingDataCalculator();
+ }
+ return packagingDataCalculator;
+ }
+
+ public void calculatePackagingData() {
+ if (calculatedPackageData) {
+ return;
+ }
+ PackagingDataCalculator pdc = this.getPackagingDataCalculator();
+ if (pdc != null) {
+ calculatedPackageData = true;
+ pdc.calculate(this);
+ }
+ }
+
+ public void fullDump() {
+ StringBuilder builder = new StringBuilder();
+ for (StackTraceElementProxy step : stackTraceElementProxyArray) {
+ String string = step.toString();
+ builder.append(CoreConstants.TAB).append(string);
+ ThrowableProxyUtil.subjoinPackagingData(builder, step);
+ builder.append(CoreConstants.LINE_SEPARATOR);
+ }
+ System.out.println(builder.toString());
+ }
}
=====================================
logback-classic/src/test/java/ch/qos/logback/classic/pattern/ThrowableProxyConverterTest.java
=====================================
@@ -22,6 +22,9 @@ import java.util.Arrays;
import java.util.List;
import ch.qos.logback.core.CoreConstants;
+import ch.qos.logback.core.testUtil.VersionUtil;
+import ch.qos.logback.classic.util.EnvUtil;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -45,6 +48,8 @@ public class ThrowableProxyConverterTest {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
+ int javaVersion = VersionUtil.getJavaMajorVersion();
+
@Before
public void setUp() throws Exception {
tpc.setContext(lc);
@@ -122,6 +127,28 @@ public class ThrowableProxyConverterTest {
verify(t);
}
+
+ @Test
+ public void cyclicCause() {
+
+ Exception e = new Exception("foo");
+ Exception e2 = new Exception(e);
+ e.initCause(e2);
+ convertToStringResult(e);
+ }
+
+ @Test
+ public void cyclicSuppressed() {
+
+ if(javaVersion < 7) {
+ return;
+ }
+ Exception e = new Exception("foo");
+ Exception e2 = new Exception(e);
+ e.addSuppressed(e2);
+ convertToStringResult(e);
+ }
+
@Test
public void withArgumentOfOne() throws Exception {
final Throwable t = TestHelper.makeNestedException(0);
@@ -217,10 +244,15 @@ public class ThrowableProxyConverterTest {
void verify(Throwable t) {
t.printStackTrace(pw);
- ILoggingEvent le = createLoggingEvent(t);
+ String result = convertToStringResult(t);
+ assertEquals(sw.toString(), result);
+ }
+
+ private String convertToStringResult(Throwable t) {
+ ILoggingEvent le = createLoggingEvent(t);
String result = tpc.convert(le);
System.out.println(result);
result = result.replace("common frames omitted", "more");
- assertEquals(sw.toString(), result);
- }
+ return result;
+ }
}
=====================================
logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextDetachingSCLTest.java
=====================================
@@ -23,8 +23,9 @@ import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.ClassicConstants;
import ch.qos.logback.classic.selector.servlet.ContextDetachingSCL;
import ch.qos.logback.classic.util.ContextSelectorStaticBinder;
-import ch.qos.logback.classic.util.MockInitialContext;
-import ch.qos.logback.classic.util.MockInitialContextFactory;
+import ch.qos.logback.core.testUtil.MockInitialContext;
+import ch.qos.logback.core.testUtil.MockInitialContextFactory;
+
import org.slf4j.LoggerFactoryFriend;
import org.slf4j.impl.StaticLoggerBinderFriend;
=====================================
logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextJNDISelectorTest.java
=====================================
@@ -23,9 +23,9 @@ import org.slf4j.impl.StaticLoggerBinderFriend;
import ch.qos.logback.classic.ClassicConstants;
import ch.qos.logback.classic.util.ContextSelectorStaticBinder;
-import ch.qos.logback.classic.util.MockInitialContext;
-import ch.qos.logback.classic.util.MockInitialContextFactory;
import ch.qos.logback.core.Context;
+import ch.qos.logback.core.testUtil.MockInitialContext;
+import ch.qos.logback.core.testUtil.MockInitialContextFactory;
public class ContextJNDISelectorTest {
=====================================
logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableProxyTest.java
=====================================
@@ -15,24 +15,25 @@ package ch.qos.logback.classic.spi;
import static ch.qos.logback.classic.util.TestHelper.addSuppressed;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assume.assumeNotNull;
import static org.junit.Assume.assumeTrue;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import ch.qos.logback.classic.util.TestHelper;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import ch.qos.logback.classic.util.TestHelper;
+import ch.qos.logback.core.testUtil.VersionUtil;
+
public class ThrowableProxyTest {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
-
+ int javaVersion = VersionUtil.getJavaMajorVersion();
+
@Before
public void setUp() throws Exception {
}
@@ -159,6 +160,27 @@ public class ThrowableProxyTest {
verify(w);
}
+ // see also https://jira.qos.ch/browse/LOGBACK-1454
+ @Test
+ public void nestedLoop1() {
+ Exception e = new Exception("foo");
+ Exception e2 = new Exception(e);
+ e.initCause(e2);
+ new ThrowableProxy(e);
+ }
+
+ // see also https://jira.qos.ch/browse/LOGBACK-1454
+ @Test
+ public void nestedLoop2() {
+ if(javaVersion < 7) {
+ return;
+ }
+ Exception e = new Exception("foo");
+ Exception e2 = new Exception(e);
+ e.addSuppressed(e2);
+ new ThrowableProxy(e);
+ }
+
void someMethod() throws Exception {
throw new Exception("someMethod");
}
=====================================
logback-core/pom.xml
=====================================
@@ -8,7 +8,7 @@
<parent>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-parent</artifactId>
- <version>1.2.10</version>
+ <version>1.2.11</version>
</parent>
<artifactId>logback-core</artifactId>
@@ -86,7 +86,6 @@
<id>bundle-test-jar</id>
<phase>package</phase>
<goals>
- <goal>jar</goal>
<goal>test-jar</goal>
</goals>
</execution>
@@ -124,4 +123,4 @@
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
=====================================
logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
=====================================
@@ -135,7 +135,7 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
addInfo("Looking up javax.mail.Session at JNDI location [" + jndiLocation + "]");
try {
Context initialContext = JNDIUtil.getInitialContext();
- Object obj = JNDIUtil.lookup(initialContext, jndiLocation);
+ Object obj = JNDIUtil.lookupObject(initialContext, jndiLocation);
return (Session) obj;
} catch (Exception e) {
addError("Failed to obtain javax.mail.Session from JNDI location [" + jndiLocation + "]");
@@ -156,7 +156,7 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
LoginAuthenticator loginAuthenticator = null;
- if (username != null) {
+ if (!OptionHelper.isEmpty(username)) {
loginAuthenticator = new LoginAuthenticator(username, password);
props.put("mail.smtp.auth", "true");
}
@@ -543,7 +543,7 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
if (to == null || to.length() == 0) {
throw new IllegalArgumentException("Null or empty <to> property");
}
- PatternLayoutBase plb = makeNewToPatternLayout(to.trim());
+ PatternLayoutBase<E> plb = makeNewToPatternLayout(to.trim());
plb.setContext(context);
plb.start();
this.toPatternLayoutList.add(plb);
@@ -553,7 +553,7 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
public List<String> getToAsListOfString() {
List<String> toList = new ArrayList<String>();
- for (PatternLayoutBase plb : toPatternLayoutList) {
+ for (PatternLayoutBase<E> plb : toPatternLayoutList) {
toList.add(plb.getPattern());
}
return toList;
=====================================
logback-core/src/main/java/ch/qos/logback/core/util/JNDIUtil.java
=====================================
@@ -15,6 +15,8 @@ package ch.qos.logback.core.util;
import static ch.qos.logback.core.CoreConstants.JNDI_JAVA_NAMESPACE;
+import java.util.Hashtable;
+
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@@ -23,33 +25,47 @@ import javax.naming.NamingException;
* A simple utility class to create and use a JNDI Context.
*
* @author Ceki Gülcü
- * @author Michael Osipov
+ * @author Michael Osipov
* @author Sébastien Pennec
*
*/
public class JNDIUtil {
- static final String RESTRICTION_MSG = "JNDI name must start with " + JNDI_JAVA_NAMESPACE + " but was ";
+ static final String RESTRICTION_MSG = "JNDI name must start with " + JNDI_JAVA_NAMESPACE + " but was ";
public static Context getInitialContext() throws NamingException {
- return new InitialContext();
- }
+ return new InitialContext();
+ }
+
+ public static Context getInitialContext(Hashtable<?,?> props) throws NamingException {
+ return new InitialContext(props);
+ }
- public static String lookup(Context ctx, String name) throws NamingException {
- if (ctx == null) {
- return null;
- }
+ public static Object lookupObject(Context ctx, String name) throws NamingException {
+ if (ctx == null) {
+ return null;
+ }
- if (OptionHelper.isEmpty(name)) {
- return null;
- }
+ if (OptionHelper.isEmpty(name)) {
+ return null;
+ }
- if (!name.startsWith(JNDI_JAVA_NAMESPACE)) {
- throw new NamingException(RESTRICTION_MSG + name);
- }
+ jndiNameSecurityCheck(name);
Object lookup = ctx.lookup(name);
- return lookup == null ? null : lookup.toString();
- }
+ return lookup;
+ }
+
+ private static void jndiNameSecurityCheck(String name) throws NamingException {
+ if (!name.startsWith(JNDI_JAVA_NAMESPACE)) {
+ throw new NamingException(RESTRICTION_MSG + name);
+ }
+ }
+
+ public static String lookupString(Context ctx, String name) throws NamingException {
+ Object lookup = lookupObject(ctx, name);
+ return (String) lookup;
+ }
+
}
=====================================
logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java
=====================================
@@ -17,7 +17,6 @@ import java.lang.reflect.Constructor;
import java.util.Properties;
import ch.qos.logback.core.Context;
-import ch.qos.logback.core.CoreConstants;
import ch.qos.logback.core.spi.ContextAware;
import ch.qos.logback.core.spi.PropertyContainer;
import ch.qos.logback.core.spi.ScanException;
@@ -258,7 +257,7 @@ public class OptionHelper {
}
public static boolean isEmpty(String str) {
- return ((str == null) || CoreConstants.EMPTY_STRING.equals(str));
+ return ((str == null) || str.length() == 0);
}
}
=====================================
logback-classic/src/test/java/ch/qos/logback/classic/util/MockInitialContext.java → logback-core/src/test/java/ch/qos/logback/core/testUtil/MockInitialContext.java
=====================================
@@ -11,7 +11,7 @@
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
-package ch.qos.logback.classic.util;
+package ch.qos.logback.core.testUtil;
import java.util.HashMap;
import java.util.Map;
=====================================
logback-classic/src/test/java/ch/qos/logback/classic/util/MockInitialContextFactory.java → logback-core/src/test/java/ch/qos/logback/core/testUtil/MockInitialContextFactory.java
=====================================
@@ -11,7 +11,7 @@
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
-package ch.qos.logback.classic.util;
+package ch.qos.logback.core.testUtil;
import java.util.Hashtable;
=====================================
logback-core/src/test/java/ch/qos/logback/core/testUtil/VersionUtil.java
=====================================
@@ -0,0 +1,52 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2022, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package ch.qos.logback.core.testUtil;
+
+public class VersionUtil {
+
+ static final int DEFAULT_GUESS = 6;
+
+ static public int getJavaMajorVersion() {
+ String javaVersionString = System.getProperty("java.version");
+ int result = getJavaMajorVersion(javaVersionString);
+ return result;
+ }
+
+ static public int getJavaMajorVersion(String versionString) {
+ if (versionString == null)
+ return DEFAULT_GUESS;
+ if (versionString.startsWith("1.")) {
+ return versionString.charAt(2) - '0';
+ } else {
+ String firstDigits = extractFirstDigits(versionString);
+ try {
+ return Integer.parseInt(firstDigits);
+ } catch(NumberFormatException e) {
+ return DEFAULT_GUESS;
+ }
+ }
+ }
+
+ private static String extractFirstDigits(String versionString) {
+ StringBuffer buf = new StringBuffer();
+ for (char c : versionString.toCharArray()) {
+ if (Character.isDigit(c))
+ buf.append(c);
+ else
+ break;
+ }
+ return buf.toString();
+
+ }
+}
=====================================
logback-core/src/test/java/ch/qos/logback/core/testUtil/VersionUtilTest.java
=====================================
@@ -0,0 +1,33 @@
+package ch.qos.logback.core.testUtil;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class VersionUtilTest {
+
+
+ @Test
+ public void test() {
+ System.out.println(System.getProperty("java.version"));
+ assertEquals(6, VersionUtil.getJavaMajorVersion("1.6"));
+ assertEquals(7, VersionUtil.getJavaMajorVersion("1.7.0_21-b11"));
+ assertEquals(8, VersionUtil.getJavaMajorVersion("1.8.0_25"));
+ }
+
+ @Test
+ public void testJava9() {
+ assertEquals(9, VersionUtil.getJavaMajorVersion("9"));
+ assertEquals(9, VersionUtil.getJavaMajorVersion("9.12"));
+ assertEquals(9, VersionUtil.getJavaMajorVersion("9ea"));
+
+ }
+
+ @Test
+ public void testJava11() {
+ assertEquals(11, VersionUtil.getJavaMajorVersion("11"));
+ assertEquals(11, VersionUtil.getJavaMajorVersion("11.612"));
+
+ }
+
+}
=====================================
logback-core/src/test/java/ch/qos/logback/core/util/CoreTestConstants.java
=====================================
@@ -29,4 +29,5 @@ public class CoreTestConstants {
public static final String BASH_PATH_ON_LINUX = "bash";
public static final String SLOW_JENKINS = "slowJenkins";
+ public static final String JAVA_NAMING_FACTORY_INITIAL = "java.naming.factory.initial";
}
=====================================
logback-core/src/test/java/ch/qos/logback/core/util/JNDIUtilTest.java
=====================================
@@ -1,23 +1,28 @@
package ch.qos.logback.core.util;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingException;
import org.junit.Test;
+import ch.qos.logback.core.testUtil.MockInitialContextFactory;
+
public class JNDIUtilTest {
@Test
public void ensureJavaNameSpace() throws NamingException {
- Context ctxt = JNDIUtil.getInitialContext();
try {
- JNDIUtil.lookup(ctxt, "ldap:...");
+ Context ctxt = JNDIUtil.getInitialContext();
+ JNDIUtil.lookupString(ctxt, "ldap:...");
} catch (NamingException e) {
String excaptionMsg = e.getMessage();
- if(excaptionMsg.startsWith(JNDIUtil.RESTRICTION_MSG))
+ if (excaptionMsg.startsWith(JNDIUtil.RESTRICTION_MSG))
return;
else {
fail("unexpected exception " + e);
@@ -27,4 +32,18 @@ public class JNDIUtilTest {
fail("Should aNot yet implemented");
}
+ @Test
+ public void testToStringCast() throws NamingException {
+ Hashtable<String, String> props = new Hashtable<String, String>();
+ props.put(CoreTestConstants.JAVA_NAMING_FACTORY_INITIAL, MockInitialContextFactory.class.getCanonicalName());
+ Context ctxt = JNDIUtil.getInitialContext(props);
+ String x = JNDIUtil.lookupString(ctxt, "java:comp:/inexistent");
+ assertNull(x);
+ }
+
+ public String castToString(Object input) {
+ String a = (String) input;
+ return a;
+ }
+
}
=====================================
logback-examples/pom.xml
=====================================
@@ -8,7 +8,7 @@
<parent>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-parent</artifactId>
- <version>1.2.10</version>
+ <version>1.2.11</version>
</parent>
<artifactId>logback-examples</artifactId>
@@ -100,4 +100,4 @@
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
=====================================
logback-site/pom.xml
=====================================
@@ -7,7 +7,7 @@
<parent>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-parent</artifactId>
- <version>1.2.10</version>
+ <version>1.2.11</version>
</parent>
<artifactId>logback-site</artifactId>
=====================================
pom.xml
=====================================
@@ -7,7 +7,7 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-parent</artifactId>
- <version>1.2.10</version>
+ <version>1.2.11</version>
<packaging>pom</packaging>
<name>Logback-Parent</name>
@@ -47,6 +47,7 @@
</modules>
<properties>
+ <project.build.outputTimestamp>2022-03-05T19:45:00Z</project.build.outputTimestamp>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -71,11 +72,12 @@
<maven-javadoc-plugin.version>3.1.0</maven-javadoc-plugin.version>
<maven-source-plugin.version>3.2.0</maven-source-plugin.version>
<maven-license-plugin.version>3.0</maven-license-plugin.version>
- <maven-jar-plugin.version>2.6</maven-jar-plugin.version>
+ <maven-jar-plugin.version>3.2.2</maven-jar-plugin.version>
<maven-jxr-plugin.version>3.1.1</maven-jxr-plugin.version>
<maven-deploy-plugin.version>3.0.0-M1</maven-deploy-plugin.version>
<cobertura.maven.plugin.version>2.7</cobertura.maven.plugin.version>
-
+ <maven-bundle-plugin.version>5.1.4</maven-bundle-plugin.version>
+
</properties>
<developers>
@@ -286,7 +288,7 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
- <version>2.5.4</version>
+ <version>${maven-bundle-plugin.version}</version>
</plugin>
<plugin>
@@ -348,8 +350,6 @@
</configuration>
</plugin>
-
-
<!-- ================ site plugin ==================== -->
<plugin>
@@ -435,6 +435,33 @@
</distributionManagement>
<profiles>
+
+ <profile>
+ <id>java6</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-toolchains-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>toolchain</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <toolchains>
+ <jdk>
+ <version>1.6</version>
+ </jdk>
+ </toolchains>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
<profile>
<id>testSkip</id>
<properties>
View it on GitLab: https://salsa.debian.org/java-team/logback/-/compare/d3d1d09896e61f76fe93a6dad3b5e23931915b5f...b004347905a788eaaabb4dc9c506b3e8feffd553
--
View it on GitLab: https://salsa.debian.org/java-team/logback/-/compare/d3d1d09896e61f76fe93a6dad3b5e23931915b5f...b004347905a788eaaabb4dc9c506b3e8feffd553
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/20220323/23af7fff/attachment.htm>
More information about the pkg-java-commits
mailing list