Commit daabd418 authored by Emmanuel Bourg's avatar Emmanuel Bourg

Update upstream source from tag 'upstream/2.11.0'

Update to upstream version '2.11.0'
with Debian dir 5e0aa4df013567ceb7e42512c8863ea0841ec05a
parents 8e429029 6d16824b
This diff is collapsed.
......@@ -34,7 +34,7 @@
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>/home/jenkins/tools/java/latest1.7</jdkHome>
<jdkHome>/home/jenkins/tools/java/latest1.8</jdkHome>
</configuration>
</toolchain>
<toolchain>
......
......@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
<version>2.10.0</version>
<version>2.11.0</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-1.2-api</artifactId>
......
......@@ -51,9 +51,11 @@ public abstract class AppenderSkeleton implements Appender, OptionHandler {
super();
}
@Override
public void activateOptions() {
}
@Override
public void addFilter(Filter newFilter) {
if(headFilter == null) {
headFilter = tailFilter = newFilter;
......@@ -65,17 +67,21 @@ public abstract class AppenderSkeleton implements Appender, OptionHandler {
protected abstract void append(LoggingEvent event);
@Override
public void clearFilters() {
headFilter = tailFilter = null;
}
@Override
public void finalize() {
}
@Override
public ErrorHandler getErrorHandler() {
return this.errorHandler;
}
@Override
public Filter getFilter() {
return headFilter;
}
......@@ -84,10 +90,12 @@ public abstract class AppenderSkeleton implements Appender, OptionHandler {
return headFilter;
}
@Override
public Layout getLayout() {
return layout;
}
@Override
public final String getName() {
return this.name;
}
......@@ -104,6 +112,7 @@ public abstract class AppenderSkeleton implements Appender, OptionHandler {
* This method is never going to be called in Log4j 2 so there isn't much point in having any code in it.
* @param event The LoggingEvent.
*/
@Override
public void doAppend(LoggingEvent event) {
}
......@@ -112,16 +121,19 @@ public abstract class AppenderSkeleton implements Appender, OptionHandler {
*
* @since 0.9.0
*/
@Override
public synchronized void setErrorHandler(ErrorHandler eh) {
if (eh != null) {
this.errorHandler = eh;
}
}
@Override
public void setLayout(Layout layout) {
this.layout = layout;
}
@Override
public void setName(String name) {
this.name = name;
}
......
......@@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.FileSystemException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.TimeUnit;
......@@ -167,10 +168,15 @@ public class Log4j1ConfigurationFactoryTest {
try {
final Configuration configuration = getConfiguration("config-1.2/log4j-system-properties-1.properties");
final RollingFileAppender appender = configuration.getAppender("RFA");
appender.stop(10, TimeUnit.SECONDS);
System.out.println("expected: " + tempFileName + " Actual: " + appender.getFileName());
assertEquals(tempFileName, appender.getFileName());
} finally {
Files.deleteIfExists(tempFilePath);
try {
Files.deleteIfExists(tempFilePath);
} catch (FileSystemException e) {
e.printStackTrace();
}
}
}
......
......@@ -16,16 +16,15 @@
*/
package org.apache.log4j.layout;
import static org.junit.Assert.assertEquals;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.impl.ContextDataFactory;
import org.apache.logging.log4j.core.impl.Log4jLogEvent;
import org.apache.logging.log4j.message.SimpleMessage;
import org.apache.logging.log4j.util.StringMap;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
public class Log4j1XmlLayoutTest {
@Test
......@@ -53,9 +52,9 @@ public class Log4j1XmlLayoutTest {
public void testWithPropertiesAndLocationInfo() {
final Log4j1XmlLayout layout = Log4j1XmlLayout.createLayout(true, true);
final Map<String, String> contextMap = new HashMap<>(2);
contextMap.put("key1", "value1");
contextMap.put("key2", "value2");
final StringMap contextMap = ContextDataFactory.createContextData(2);
contextMap.putValue("key1", "value1");
contextMap.putValue("key2", "value2");
final Log4jLogEvent event = Log4jLogEvent.newBuilder()
.setLoggerName("a.B")
.setLevel(Level.INFO)
......@@ -63,7 +62,7 @@ public class Log4j1XmlLayoutTest {
.setTimeMillis(System.currentTimeMillis() + 17)
.setIncludeLocation(true)
.setSource(new StackTraceElement("pack.MyClass", "myMethod", "MyClass.java", 17))
.setContextMap(contextMap)
.setContextData(contextMap)
.build();
final String result = layout.toSerializable(event);
......
......@@ -16,58 +16,57 @@
*/
package org.apache.log4j.pattern;
import static org.junit.Assert.assertEquals;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.impl.ContextDataFactory;
import org.apache.logging.log4j.core.impl.Log4jLogEvent;
import org.apache.logging.log4j.message.SimpleMessage;
import org.apache.logging.log4j.util.StringMap;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
public class Log4j1MdcPatternConverterTest {
@Test
public void testConverter0() {
final Map<String, String> contextMap = new HashMap<>(0);
final StringMap contextMap = ContextDataFactory.createContextData(0);
final String expected = "{}";
test(contextMap, expected, null);
}
@Test
public void testConverter1() {
final Map<String, String> contextMap = new HashMap<>(1);
contextMap.put("key1", "value1");
final StringMap contextMap = ContextDataFactory.createContextData(1);
contextMap.putValue("key1", "value1");
final String expected = "{{key1,value1}}";
test(contextMap, expected, null);
}
@Test
public void testConverter2() {
final Map<String, String> contextMap = new HashMap<>(2);
contextMap.put("key1", "value1");
contextMap.put("key2", "value2");
final StringMap contextMap = ContextDataFactory.createContextData(2);
contextMap.putValue("key1", "value1");
contextMap.putValue("key2", "value2");
final String expected = "{{key1,value1}{key2,value2}}";
test(contextMap, expected, null);
}
@Test
public void testConverterWithKey() {
final Map<String, String> contextMap = new HashMap<>(2);
contextMap.put("key1", "value1");
contextMap.put("key2", "value2");
final StringMap contextMap = ContextDataFactory.createContextData(2);
contextMap.putValue("key1", "value1");
contextMap.putValue("key2", "value2");
final String expected = "value1";
test(contextMap, expected, new String[] {"key1"});
}
private void test(final Map<String, String> contextMap, final String expected, final String[] options) {
private void test(final StringMap contextMap, final String expected, final String[] options) {
final LogEvent event = Log4jLogEvent.newBuilder()
.setLoggerName("MyLogger")
.setLevel(Level.DEBUG)
.setMessage(new SimpleMessage("Hello"))
.setContextMap(contextMap)
.setContextData(contextMap)
.build();
final StringBuilder sb = new StringBuilder();
final Log4j1MdcPatternConverter converter = Log4j1MdcPatternConverter.newInstance(options);
......
......@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
<version>2.10.0</version>
<version>2.11.0</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-api-java9</artifactId>
......@@ -142,7 +142,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<version>${deploy.plugin.version}</version>
<configuration>
<skip>true</skip>
</configuration>
......
......@@ -32,17 +32,12 @@
<include>**/*.class</include>
</includes>
<excludes>
<exclude>module-info.class</exclude>
<exclude>**/Dummy.class</exclude>
<exclude>**/spi/Provider.class</exclude>
<exclude>**/util/PropertySource.class</exclude>
<exclude>**/message/ThreadDumpMessage.class</exclude>
<exclude>**/message/ThreadDumpMessage$ThreadInfoFactory.class</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${project.build.outputDirectory}</directory>
<outputDirectory>/classes</outputDirectory>
<includes>
<include>module-info.class</include>
</includes>
</fileSet>
</fileSets>
</assembly>
......@@ -21,5 +21,8 @@ module org.apache.logging.log4j {
exports org.apache.logging.log4j.spi;
exports org.apache.logging.log4j.status;
exports org.apache.logging.log4j.util;
uses org.apache.logging.log4j.spi.Provider;
}
\ No newline at end of file
uses org.apache.logging.log4j.util.PropertySource;
uses org.apache.logging.log4j.message.ThreadDumpMessage.ThreadInfoFactory;
}
/*
* 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;
/**
* This is a dummy class and is only here to allow module-info.java to compile. It will not
* be copied into the log4j-api module.
*/
public class PropertySource {
}
/*
* 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.message;
/**
* This is a dummy class and is only here to allow module-info.java to compile. It will not
* be copied into the log4j-api module.
*/
public class ThreadDumpMessage {
public static interface ThreadInfoFactory {
}
}
/*
* 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.internal;
import java.io.ObjectInputFilter;
import java.util.Arrays;
import java.util.List;
public class DefaultObjectInputFilter implements ObjectInputFilter {
private static final List<String> REQUIRED_JAVA_CLASSES = Arrays.asList(
"java.math.BigDecimal",
"java.math.BigInteger",
// for Message delegate
"java.rmi.MarshalledObject",
"[B"
);
private static final List<String> REQUIRED_JAVA_PACKAGES = Arrays.asList(
"java.lang.",
"java.time",
"java.util.",
"org.apache.logging.log4j.",
"[Lorg.apache.logging.log4j."
);
private final ObjectInputFilter delegate;
public DefaultObjectInputFilter() {
delegate = null;
}
public DefaultObjectInputFilter(ObjectInputFilter filter) {
delegate = filter;
}
/**
* This is easier to use via reflection.
* @param filter The ObjectInputFilter.
* @return The DefaultObjectInputFilter.
*/
public static DefaultObjectInputFilter newInstance(ObjectInputFilter filter) {
return new DefaultObjectInputFilter(filter);
}
@Override
public Status checkInput(FilterInfo filterInfo) {
Status status = null;
if (delegate != null) {
status = delegate.checkInput(filterInfo);
if (status != Status.UNDECIDED) {
return status;
}
}
ObjectInputFilter serialFilter = ObjectInputFilter.Config.getSerialFilter();
if (serialFilter != null) {
status = serialFilter.checkInput(filterInfo);
if (status != Status.UNDECIDED) {
// The process-wide filter overrides this filter
return status;
}
}
if (filterInfo.serialClass() != null) {
String name = filterInfo.serialClass().getName();
if (isAllowedByDefault(name) || isRequiredPackage(name)) {
return Status.ALLOWED;
}
}
return Status.REJECTED;
}
private static boolean isAllowedByDefault(final String name) {
return isRequiredPackage(name) || REQUIRED_JAVA_CLASSES.contains(name);
}
private static boolean isRequiredPackage(final String name) {
for (final String packageName : REQUIRED_JAVA_PACKAGES) {
if (name.startsWith(packageName)) {
return true;
}
}
return false;
}
}
......@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
<version>2.10.0</version>
<version>2.11.0</version>
<relativePath>../</relativePath>
</parent>
<artifactId>log4j-api</artifactId>
......@@ -88,7 +88,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.1</version>
<version>3.0.2</version>
<executions>
<execution>
<id>unpack-classes</id>
......@@ -159,28 +159,51 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${manifestfile}</manifestFile>
<manifestEntries>
<Specification-Title>${project.name}</Specification-Title>
<Specification-Version>${project.version}</Specification-Version>
<Specification-Vendor>${project.organization.name}</Specification-Vendor>
<Implementation-Title>${project.name}</Implementation-Title>
<Implementation-Version>${project.version}</Implementation-Version>
<Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
<Implementation-Vendor-Id>org.apache</Implementation-Vendor-Id>
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
<X-Compile-Target-JDK>${maven.compiler.target}</X-Compile-Target-JDK>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<id>default-jar</id>
<goals>
<goal>jar</goal>
</goals>
<configuration combine.self="override">
<archive>
<manifestFile>${manifestfile}</manifestFile>
<manifestEntries>
<Specification-Title>${project.name}</Specification-Title>
<Specification-Version>${project.version}</Specification-Version>
<Specification-Vendor>${project.organization.name}</Specification-Vendor>