You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2019/06/08 18:31:25 UTC

[logging-log4j2] branch master updated (51ace0a -> acbd230)

This is an automated email from the ASF dual-hosted git repository.

mattsicker pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git.


    from 51ace0a  LOG4J2-2610 - Only update creation time if flie size is 0
     new e640883  Update copyright year
     new acbd230  Fix compilation error when using newer javac

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 NOTICE.txt                                         |  2 +-
 .../junit/{Mutable.java => ClassMatchers.java}     | 26 ++++++++++++----------
 .../logging/log4j/util/StackLocatorUtilTest.java   | 17 +++++++++++---
 3 files changed, 29 insertions(+), 16 deletions(-)
 copy log4j-api/src/test/java/org/apache/logging/log4j/junit/{Mutable.java => ClassMatchers.java} (61%)


[logging-log4j2] 02/02: Fix compilation error when using newer javac

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mattsicker pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit acbd23054492ba71878a4aeebf03c92a0bcf7aa1
Author: Matt Sicker <bo...@gmail.com>
AuthorDate: Sat Jun 8 13:26:41 2019 -0500

    Fix compilation error when using newer javac
---
 .../apache/logging/log4j/junit/ClassMatchers.java  | 37 ++++++++++++++++++++++
 .../logging/log4j/util/StackLocatorUtilTest.java   | 17 ++++++++--
 2 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/junit/ClassMatchers.java b/log4j-api/src/test/java/org/apache/logging/log4j/junit/ClassMatchers.java
new file mode 100644
index 0000000..74f6f7e
--- /dev/null
+++ b/log4j-api/src/test/java/org/apache/logging/log4j/junit/ClassMatchers.java
@@ -0,0 +1,37 @@
+/*
+ * 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.junit;
+
+import org.apache.logging.log4j.util.LoaderUtil;
+import org.hamcrest.CustomTypeSafeMatcher;
+import org.hamcrest.Matcher;
+
+public final class ClassMatchers {
+
+    private static final Matcher<String> LOADABLE_CLASS_NAME = new CustomTypeSafeMatcher<String>("a loadable class name") {
+        @Override
+        protected boolean matchesSafely(final String item) {
+            return LoaderUtil.isClassAvailable(item);
+        }
+    };
+
+    public static Matcher<String> loadableClassName() {
+        return LOADABLE_CLASS_NAME;
+    }
+
+}
diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/util/StackLocatorUtilTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/util/StackLocatorUtilTest.java
index abade29..c4becc7 100644
--- a/log4j-api/src/test/java/org/apache/logging/log4j/util/StackLocatorUtilTest.java
+++ b/log4j-api/src/test/java/org/apache/logging/log4j/util/StackLocatorUtilTest.java
@@ -16,24 +16,35 @@
  */
 package org.apache.logging.log4j.util;
 
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
 import java.util.Stack;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.BlockJUnit4ClassRunner;
 import org.junit.runners.ParentRunner;
-import sun.reflect.Reflection;
 
+import static org.apache.logging.log4j.junit.ClassMatchers.*;
+import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.*;
+import static org.junit.Assume.assumeThat;
 
 @RunWith(BlockJUnit4ClassRunner.class)
 public class StackLocatorUtilTest {
 
 
     @Test
-    public void testStackTraceEquivalence() throws Exception {
+    public void testStackTraceEquivalence() throws Throwable {
+        String reflectionClassName = "sun.reflect.Reflection";
+        assumeThat("Running in a JDK without deprecated " + reflectionClassName,
+                reflectionClassName, is(loadableClassName()));
+        Class<?> reflectionClass = LoaderUtil.loadClass(reflectionClassName);
+        MethodHandle getCallerClass = MethodHandles.lookup()
+                .findStatic(reflectionClass, "getCallerClass", MethodType.methodType(Class.class, int.class));
         for (int i = 1; i < 15; i++) {
-            final Class<?> expected = Reflection.getCallerClass(i + StackLocator.JDK_7u25_OFFSET);
+            final Class<?> expected = (Class<?>) getCallerClass.invoke(i + StackLocator.JDK_7u25_OFFSET);
             final Class<?> actual = StackLocatorUtil.getCallerClass(i);
             final Class<?> fallbackActual = Class.forName(
                 StackLocatorUtil.getStackTraceElement(i).getClassName());


[logging-log4j2] 01/02: Update copyright year

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mattsicker pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit e640883790644eab3af9dd3cdf1b44750b40d4d6
Author: Matt Sicker <bo...@gmail.com>
AuthorDate: Sat Jun 8 13:25:56 2019 -0500

    Update copyright year
---
 NOTICE.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/NOTICE.txt b/NOTICE.txt
index bd95322..a241a12 100644
--- a/NOTICE.txt
+++ b/NOTICE.txt
@@ -1,5 +1,5 @@
 Apache Log4j
-Copyright 1999-2017 Apache Software Foundation
+Copyright 1999-2019 Apache Software Foundation
 
 This product includes software developed at
 The Apache Software Foundation (http://www.apache.org/).