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

pkarwasz pushed a commit to branch fix/2.x/remove-dinosaurs
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 4a9c2b26e95c55e34833c5862ea5db0e477d6765
Author: Piotr P. Karwasz <[email protected]>
AuthorDate: Tue Oct 1 11:17:29 2024 +0200

    Remove ancient test fixtures and dependencies
    
    This removes the test dependency on `oro:oro` and the `VelocityTest`, which 
uses Apache Velocity 1.7 for no clear reason.
---
 log4j-1.2-api/pom.xml                              |  34 ++++---
 .../test/java/org/apache/log4j/VelocityTest.java   |  60 ------------
 .../log4j/util/AbsoluteDateAndTimeFilter.java      |  35 -------
 .../org/apache/log4j/util/AbsoluteTimeFilter.java  |  34 -------
 .../test/java/org/apache/log4j/util/Compare.java   | 106 +--------------------
 .../java/org/apache/log4j/util/ControlFilter.java  |  10 +-
 .../log4j/util/EnhancedJunitTestRunnerFilter.java  |  64 -------------
 .../log4j/util/EnhancedLineNumberFilter.java       |  41 --------
 .../test/java/org/apache/log4j/util/Filter.java    |  15 +--
 .../java/org/apache/log4j/util/ISO8601Filter.java  |  11 +--
 .../apache/log4j/util/JunitTestRunnerFilter.java   |  25 +++--
 .../org/apache/log4j/util/LineNumberFilter.java    |  15 ++-
 .../org/apache/log4j/util/RelativeTimeFilter.java  |  35 -------
 .../org/apache/log4j/util/SunReflectFilter.java    |  18 ++--
 .../java/org/apache/log4j/util/Transformer.java    |  18 +---
 .../apache/log4j/util/XMLLineAttributeFilter.java  |  35 -------
 .../{XMLTimestampFilter.java => package-info.java} |  16 +---
 log4j-1.2-api/src/test/resources/hello.vm          |   6 --
 18 files changed, 58 insertions(+), 520 deletions(-)

diff --git a/log4j-1.2-api/pom.xml b/log4j-1.2-api/pom.xml
index 097921ad56..090439a215 100644
--- a/log4j-1.2-api/pom.xml
+++ b/log4j-1.2-api/pom.xml
@@ -51,85 +51,91 @@
   </properties>
 
   <dependencies>
+
     <!-- Used for JMS appenders (needs an implementation of course) -->
     <dependency>
       <groupId>javax.jms</groupId>
       <artifactId>javax.jms-api</artifactId>
       <scope>provided</scope>
-      <optional>true</optional>
     </dependency>
-    <!-- Log4j Runtime -->
+
+    <dependency>
+      <groupId>org.jspecify</groupId>
+      <artifactId>jspecify</artifactId>
+      <scope>test</scope>
+    </dependency>
+
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-api</artifactId>
     </dependency>
+
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-core</artifactId>
       <optional>true</optional>
     </dependency>
+
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-api-test</artifactId>
       <scope>test</scope>
     </dependency>
+
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-core-test</artifactId>
       <scope>test</scope>
     </dependency>
+
     <dependency>
       <groupId>org.awaitility</groupId>
       <artifactId>awaitility</artifactId>
       <scope>test</scope>
     </dependency>
+
     <dependency>
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
       <scope>test</scope>
     </dependency>
+
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-lang3</artifactId>
       <scope>test</scope>
     </dependency>
+
     <dependency>
       <groupId>com.fasterxml.jackson.dataformat</groupId>
       <artifactId>jackson-dataformat-xml</artifactId>
       <scope>test</scope>
     </dependency>
+
     <dependency>
       <groupId>org.junit.jupiter</groupId>
       <artifactId>junit-jupiter-engine</artifactId>
       <scope>test</scope>
     </dependency>
+
     <dependency>
       <groupId>org.junit.jupiter</groupId>
       <artifactId>junit-jupiter-params</artifactId>
       <scope>test</scope>
     </dependency>
-    <!-- JUnit -->
+
     <dependency>
       <groupId>org.junit.vintage</groupId>
       <artifactId>junit-vintage-engine</artifactId>
       <scope>test</scope>
     </dependency>
+
     <dependency>
       <groupId>org.mockito</groupId>
       <artifactId>mockito-core</artifactId>
       <scope>test</scope>
     </dependency>
-    <!-- 1.2 tests -->
-    <dependency>
-      <groupId>oro</groupId>
-      <artifactId>oro</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.velocity</groupId>
-      <artifactId>velocity</artifactId>
-      <scope>test</scope>
-    </dependency>
+
   </dependencies>
 
   <profiles>
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/VelocityTest.java 
b/log4j-1.2-api/src/test/java/org/apache/log4j/VelocityTest.java
deleted file mode 100644
index d46e49cc3d..0000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/VelocityTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.log4j;
-
-import java.io.StringWriter;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configurator;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Note that this test must clean up after itself or it may cause other tests 
to fail.
- */
-public class VelocityTest {
-
-    private static LoggerContext context;
-
-    @BeforeClass
-    public static void setupClass() {
-        context = LoggerContext.getContext(false);
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-        Configurator.shutdown(context);
-        StatusLogger.getLogger().reset();
-    }
-
-    @Test
-    public void testVelocity() {
-        Velocity.init();
-        final VelocityContext vContext = new VelocityContext();
-        vContext.put("name", "Velocity");
-
-        final Template template = 
Velocity.getTemplate("target/test-classes/hello.vm");
-
-        final StringWriter sw = new StringWriter();
-
-        template.merge(vContext, sw);
-    }
-}
diff --git 
a/log4j-1.2-api/src/test/java/org/apache/log4j/util/AbsoluteDateAndTimeFilter.java
 
b/log4j-1.2-api/src/test/java/org/apache/log4j/util/AbsoluteDateAndTimeFilter.java
deleted file mode 100644
index 538e7228b7..0000000000
--- 
a/log4j-1.2-api/src/test/java/org/apache/log4j/util/AbsoluteDateAndTimeFilter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.log4j.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-public class AbsoluteDateAndTimeFilter implements Filter {
-
-    Perl5Util util = new Perl5Util();
-
-    @Override
-    public String filter(final String in) {
-        final String pat = "/" + Filter.ABSOLUTE_DATE_AND_TIME_PAT + "/";
-
-        if (util.match(pat, in)) {
-            return util.substitute("s/" + Filter.ABSOLUTE_DATE_AND_TIME_PAT + 
"//", in);
-        } else {
-            return in;
-        }
-    }
-}
diff --git 
a/log4j-1.2-api/src/test/java/org/apache/log4j/util/AbsoluteTimeFilter.java 
b/log4j-1.2-api/src/test/java/org/apache/log4j/util/AbsoluteTimeFilter.java
deleted file mode 100644
index d9c173668e..0000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/AbsoluteTimeFilter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.log4j.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-public class AbsoluteTimeFilter implements Filter {
-
-    Perl5Util util = new Perl5Util();
-
-    @Override
-    public String filter(final String in) {
-        final String pat = "/" + Filter.ABSOLUTE_TIME_PAT + "/";
-
-        if (util.match(pat, in)) {
-            return util.substitute("s/" + Filter.ABSOLUTE_TIME_PAT + "//", in);
-        }
-        return in;
-    }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/Compare.java 
b/log4j-1.2-api/src/test/java/org/apache/log4j/util/Compare.java
index 36af9f5e29..e540ba53c6 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/Compare.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/util/Compare.java
@@ -17,66 +17,12 @@
 package org.apache.log4j.util;
 
 import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 
 public class Compare {
 
-    static final int B1_NULL = -1;
-    static final int B2_NULL = -2;
-
-    public static boolean compare(final Class testClass, final String file1, 
final String file2) throws IOException {
-        try (final BufferedReader in1 = new BufferedReader(new 
FileReader(file1));
-                final BufferedReader in2 = new BufferedReader(new 
InputStreamReader(open(testClass, file2)))) {
-            return compare(testClass, file1, file2, in1, in2);
-        }
-    }
-
-    public static boolean compare(
-            final Class testClass,
-            final String file1,
-            final String file2,
-            final BufferedReader in1,
-            final BufferedReader in2)
-            throws IOException {
-
-        String s1;
-        int lineCounter = 0;
-
-        while ((s1 = in1.readLine()) != null) {
-            lineCounter++;
-
-            final String s2 = in2.readLine();
-
-            if (!s1.equals(s2)) {
-                System.out.println("Files [" + file1 + "] and [" + file2 + "] 
differ on line " + lineCounter);
-                System.out.println("One reads:  [" + s1 + "].");
-                System.out.println("Other reads:[" + s2 + "].");
-                outputFile(testClass, file1);
-                outputFile(testClass, file2);
-
-                return false;
-            }
-        }
-
-        // the second file is longer
-        if (in2.read() != -1) {
-            System.out.println("File [" + file2 + "] longer than file [" + 
file1 + "].");
-            outputFile(testClass, file1);
-            outputFile(testClass, file2);
-
-            return false;
-        }
-
-        return true;
-    }
-
-    public static boolean compare(final String file1, final String file2) 
throws FileNotFoundException, IOException {
+    public static boolean compare(final String file1, final String file2) 
throws IOException {
         try (final BufferedReader in1 = new BufferedReader(new 
FileReader(file1));
                 final BufferedReader in2 = new BufferedReader(new 
FileReader(file2))) {
 
@@ -102,54 +48,4 @@ public class Compare {
             return true;
         }
     }
-
-    private static final InputStream open(final Class testClass, final String 
fileName) throws IOException {
-        String resourceName = fileName;
-        if (fileName.startsWith("witness/")) {
-            resourceName = fileName.substring(fileName.lastIndexOf('/') + 1);
-        }
-        InputStream is = testClass.getResourceAsStream(resourceName);
-        if (is == null) {
-            final File file = new File(fileName);
-            if (file.exists()) {
-                is = new FileInputStream(file);
-            } else {
-                throw new FileNotFoundException("Resource " + resourceName + " 
not found");
-            }
-        }
-        return is;
-    }
-
-    /**
-     *
-     * Prints file on the console.
-     *
-     */
-    private static void outputFile(final Class testClass, final String file) 
throws IOException {
-        try (final InputStream is = open(testClass, file);
-                final BufferedReader in1 = new BufferedReader(new 
InputStreamReader(is))) {
-
-            String s1;
-            int lineCounter = 0;
-            System.out.println("--------------------------------");
-            System.out.println("Contents of " + file + ":");
-
-            while ((s1 = in1.readLine()) != null) {
-                lineCounter++;
-                System.out.print(lineCounter);
-
-                if (lineCounter < 10) {
-                    System.out.print("   : ");
-                } else if (lineCounter < 100) {
-                    System.out.print("  : ");
-                } else if (lineCounter < 1000) {
-                    System.out.print(" : ");
-                } else {
-                    System.out.print(": ");
-                }
-
-                System.out.println(s1);
-            }
-        }
-    }
 }
diff --git 
a/log4j-1.2-api/src/test/java/org/apache/log4j/util/ControlFilter.java 
b/log4j-1.2-api/src/test/java/org/apache/log4j/util/ControlFilter.java
index a2f872a1ae..ad1c83e479 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/ControlFilter.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/util/ControlFilter.java
@@ -17,12 +17,9 @@
 package org.apache.log4j.util;
 
 import java.util.Arrays;
-import org.apache.oro.text.perl.Perl5Util;
 
 public class ControlFilter implements Filter {
 
-    Perl5Util util = new Perl5Util();
-
     String[] allowedPatterns;
 
     public ControlFilter(final String[] allowedPatterns) {
@@ -31,11 +28,8 @@ public class ControlFilter implements Filter {
 
     @Override
     public String filter(final String in) throws UnexpectedFormatException {
-        final int len = allowedPatterns.length;
-        for (int i = 0; i < len; i++) {
-            // System.out.println("["+allowedPatterns[i]+"]");
-            if (util.match("/" + allowedPatterns[i] + "/", in)) {
-                // System.out.println("["+in+"] matched ["+allowedPatterns[i]);
+        for (String allowedPattern : allowedPatterns) {
+            if (in.matches(allowedPattern)) {
                 return in;
             }
         }
diff --git 
a/log4j-1.2-api/src/test/java/org/apache/log4j/util/EnhancedJunitTestRunnerFilter.java
 
b/log4j-1.2-api/src/test/java/org/apache/log4j/util/EnhancedJunitTestRunnerFilter.java
deleted file mode 100644
index 7b44b1c0f9..0000000000
--- 
a/log4j-1.2-api/src/test/java/org/apache/log4j/util/EnhancedJunitTestRunnerFilter.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.log4j.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-public class EnhancedJunitTestRunnerFilter implements Filter {
-    private static final String[] PATTERNS = {
-        "at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner",
-        "at org.apache.tools.ant",
-        "at junit.textui.TestRunner",
-        "at com.intellij.rt.execution.junit",
-        "at java.lang.reflect.Method.invoke",
-        "at org.apache.maven.",
-        "at org.codehaus.",
-        "at org.junit.internal.runners.",
-        "at junit.framework.JUnit4TestAdapter"
-    };
-
-    private final Perl5Util util = new Perl5Util();
-
-    public EnhancedJunitTestRunnerFilter() {}
-
-    /**
-     * Filter out stack trace lines coming from the various JUnit TestRunners.
-     */
-    @Override
-    public String filter(final String in) {
-        if (in == null) {
-            return null;
-        }
-
-        //
-        // restore the one instance of Method.invoke that we actually want
-        //
-        if (in.indexOf("at junit.framework.TestCase.runTest") != -1) {
-            return "\tat java.lang.reflect.Method.invoke(X)\n\t" + in.trim();
-        }
-
-        for (final String element : PATTERNS) {
-            if (in.indexOf(element) != -1) {
-                return null;
-            }
-        }
-        if (util.match("/\\sat /", in)) {
-            return "\t" + in.trim();
-        }
-        return in;
-    }
-}
diff --git 
a/log4j-1.2-api/src/test/java/org/apache/log4j/util/EnhancedLineNumberFilter.java
 
b/log4j-1.2-api/src/test/java/org/apache/log4j/util/EnhancedLineNumberFilter.java
deleted file mode 100644
index fa8132adf0..0000000000
--- 
a/log4j-1.2-api/src/test/java/org/apache/log4j/util/EnhancedLineNumberFilter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.log4j.util;
-
-import java.util.regex.Pattern;
-
-public class EnhancedLineNumberFilter implements Filter {
-    private final Pattern linePattern;
-    private final Pattern nativePattern;
-
-    public EnhancedLineNumberFilter() {
-        linePattern = Pattern.compile("\\(.*:\\d{1,4}\\)");
-        nativePattern = Pattern.compile("\\(Native Method\\)");
-    }
-
-    @Override
-    public String filter(final String in) {
-
-        if (linePattern.matcher(in).find()) {
-            return linePattern.matcher(in).replaceAll("(X)");
-        } else if (nativePattern.matcher(in).find()) {
-            return nativePattern.matcher(in).replaceAll("(X)");
-        } else {
-            return in;
-        }
-    }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/Filter.java 
b/log4j-1.2-api/src/test/java/org/apache/log4j/util/Filter.java
index f3ebdcea69..8c6fab310c 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/Filter.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/util/Filter.java
@@ -16,19 +16,12 @@
  */
 package org.apache.log4j.util;
 
-public interface Filter {
-
-    final String BASIC_PAT = "\\[main\\] (FATAL|ERROR|WARN|INFO|DEBUG)";
-    final String ISO8601_PAT = "^\\d{4}-\\d{2}-\\d{2} 
\\d{2}:\\d{2}:\\d{2},\\d{3}";
+import org.jspecify.annotations.Nullable;
 
-    // 06 avr. 2002 18:36:32,036
-    // 18 fevr. 2002 20:05:36,222
-    public static final String ABSOLUTE_DATE_AND_TIME_PAT = "^\\d{1,2} 
.{2,6}\\.? 2\\d{3} \\d{2}:\\d{2}:\\d{2},\\d{3}";
-
-    // 18:54:19,201
-    public static final String ABSOLUTE_TIME_PAT = 
"^\\d{2}:\\d{2}:\\d{2},\\d{3}";
+public interface Filter {
 
-    public static final String RELATIVE_TIME_PAT = "^\\d{1,10}";
+    String ISO8601_PAT = "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3}";
 
+    @Nullable
     String filter(String in) throws UnexpectedFormatException;
 }
diff --git 
a/log4j-1.2-api/src/test/java/org/apache/log4j/util/ISO8601Filter.java 
b/log4j-1.2-api/src/test/java/org/apache/log4j/util/ISO8601Filter.java
index 023337e9af..0ee54d4b05 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/ISO8601Filter.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/util/ISO8601Filter.java
@@ -16,19 +16,10 @@
  */
 package org.apache.log4j.util;
 
-import org.apache.oro.text.perl.Perl5Util;
-
 public class ISO8601Filter implements Filter {
 
-    Perl5Util util = new Perl5Util();
-
     @Override
     public String filter(final String in) {
-        final String pat = "/" + ISO8601_PAT + "/";
-
-        if (util.match(pat, in)) {
-            return util.substitute("s/" + ISO8601_PAT + "//", in);
-        }
-        return in;
+        return in.replaceFirst(ISO8601_PAT, "");
     }
 }
diff --git 
a/log4j-1.2-api/src/test/java/org/apache/log4j/util/JunitTestRunnerFilter.java 
b/log4j-1.2-api/src/test/java/org/apache/log4j/util/JunitTestRunnerFilter.java
index bd18f8893a..6a77d457e7 100644
--- 
a/log4j-1.2-api/src/test/java/org/apache/log4j/util/JunitTestRunnerFilter.java
+++ 
b/log4j-1.2-api/src/test/java/org/apache/log4j/util/JunitTestRunnerFilter.java
@@ -16,35 +16,32 @@
  */
 package org.apache.log4j.util;
 
-import org.apache.oro.text.perl.Perl5Util;
+import java.util.regex.Pattern;
+import org.jspecify.annotations.Nullable;
 
 public class JunitTestRunnerFilter implements Filter {
-    Perl5Util util = new Perl5Util();
 
     /**
      * Filter out stack trace lines coming from the various JUnit TestRunners.
      */
     @Override
-    public String filter(final String in) {
-        if (in == null) {
-            return null;
-        }
+    public @Nullable String filter(final String in) {
 
-        if (util.match("/at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner/", in)) {
+        if (in.contains("at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner")) {
             return null;
-        } else if (util.match("/at 
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner/", in)) {
+        } else if (in.contains("at 
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner")) {
             return null;
-        } else if (util.match("/at com.intellij/", in)) {
+        } else if (in.contains("at com.intellij")) {
             return null;
-        } else if (in.indexOf("at junit.") >= 0 && in.indexOf("ui.TestRunner") 
>= 0) {
+        } else if (in.contains("at junit.") && in.contains("ui.TestRunner")) {
             return null;
-        } else if (in.indexOf("org.apache.maven") >= 0) {
+        } else if (in.contains("org.apache.maven")) {
             return null;
-        } else if (in.indexOf("junit.internal") >= 0) {
+        } else if (in.contains("junit.internal")) {
             return null;
-        } else if (in.indexOf("JUnit4TestAdapter") >= 0) {
+        } else if (in.contains("JUnit4TestAdapter")) {
             return null;
-        } else if (util.match("/\\sat /", in)) {
+        } else if (Pattern.compile("\\sat ").matcher(in).find()) {
             return "\t" + in.trim();
         } else {
             return in;
diff --git 
a/log4j-1.2-api/src/test/java/org/apache/log4j/util/LineNumberFilter.java 
b/log4j-1.2-api/src/test/java/org/apache/log4j/util/LineNumberFilter.java
index 3148d927eb..d3bba3f994 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/LineNumberFilter.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/util/LineNumberFilter.java
@@ -16,20 +16,19 @@
  */
 package org.apache.log4j.util;
 
-import org.apache.oro.text.perl.Perl5Util;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 public class LineNumberFilter implements Filter {
 
-    Perl5Util util = new Perl5Util();
+    private static final Pattern LINE_NUMBER_PATTERN = 
Pattern.compile(":\\d+\\)");
 
     @Override
     public String filter(final String in) {
-        if (util.match("/\\(.*:\\d{1,4}\\)/", in)) {
-            return util.substitute("s/:\\d{1,4}\\)/:XXX)/", in);
+        Matcher matcher = LINE_NUMBER_PATTERN.matcher(in);
+        if (matcher.find()) {
+            return matcher.replaceFirst(":XXX");
         }
-        if (in.indexOf(", Compiled Code") >= 0) {
-            return util.substitute("s/, Compiled Code/:XXX/", in);
-        }
-        return in;
+        return in.replaceFirst(", Compiled Code", ":XXX");
     }
 }
diff --git 
a/log4j-1.2-api/src/test/java/org/apache/log4j/util/RelativeTimeFilter.java 
b/log4j-1.2-api/src/test/java/org/apache/log4j/util/RelativeTimeFilter.java
deleted file mode 100644
index 3f7c251478..0000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/RelativeTimeFilter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.log4j.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-public class RelativeTimeFilter implements Filter {
-
-    Perl5Util util = new Perl5Util();
-
-    @Override
-    public String filter(final String in) {
-        final String pat = "/" + Filter.RELATIVE_TIME_PAT + "/";
-
-        if (util.match(pat, in)) {
-            // System.out.println("Removing relative time from line ["+in+"]");
-            return util.substitute("s/" + Filter.RELATIVE_TIME_PAT + "//", in);
-        }
-        return in;
-    }
-}
diff --git 
a/log4j-1.2-api/src/test/java/org/apache/log4j/util/SunReflectFilter.java 
b/log4j-1.2-api/src/test/java/org/apache/log4j/util/SunReflectFilter.java
index 07866f0294..c54755bcb9 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/SunReflectFilter.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/util/SunReflectFilter.java
@@ -16,27 +16,23 @@
  */
 package org.apache.log4j.util;
 
-import org.apache.oro.text.perl.Perl5Util;
+import org.jspecify.annotations.Nullable;
 
 /**
  * The sun.reflect.* and java.lang.reflect.* lines are not present in all JDKs.
  */
 public class SunReflectFilter implements Filter {
-    Perl5Util util = new Perl5Util();
 
     @Override
-    public String filter(final String in) {
-        if ((in == null) || util.match("/at sun.reflect/", in) || 
(in.indexOf("at java.lang.reflect.") >= 0)) {
+    public @Nullable String filter(final String in) {
+        if (in.contains("at sun.reflect") || in.contains("at 
java.lang.reflect")) {
             return null;
         }
-        if (in.indexOf("Compiled Code") >= 0) {
-            if (in.indexOf("junit.framework.TestSuite") >= 0) {
-                return util.substitute("s/Compiled Code/TestSuite.java:XXX/", 
in);
+        if (in.contains("Compiled Code")) {
+            if (in.contains("junit.framework.TestSuite")) {
+                return in.replaceFirst("Compiled Code", "TestSuite.java:XXX");
             }
         }
-        if (util.match("/\\(Method.java:.*\\)/", in)) {
-            return util.substitute("s/\\(Method.java:.*\\)/(Native Method)/", 
in);
-        }
-        return in;
+        return in.replaceFirst("\\(Method.java:.*\\)", "(Native Method)");
     }
 }
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/Transformer.java 
b/log4j-1.2-api/src/test/java/org/apache/log4j/util/Transformer.java
index d28d4003eb..3c6e498344 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/Transformer.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/util/Transformer.java
@@ -24,20 +24,6 @@ import java.io.PrintStream;
 
 public class Transformer {
 
-    public static void transform(final String in, final String out, final 
Filter filter)
-            throws IOException, UnexpectedFormatException {
-
-        String line;
-        final BufferedReader input = new BufferedReader(new FileReader(in));
-        final PrintStream output = new PrintStream(new FileOutputStream(out));
-
-        // Initialization of input and output omitted
-        while ((line = input.readLine()) != null) {
-            line = filter.filter(line);
-            output.println(line);
-        }
-    }
-
     public static void transform(final String in, final String out, final 
Filter[] filters)
             throws IOException, UnexpectedFormatException {
 
@@ -49,7 +35,9 @@ public class Transformer {
         while ((line = input.readLine()) != null) {
             // apply all filters
             for (final Filter filter : filters) {
-                line = filter.filter(line);
+                if (line != null) {
+                    line = filter.filter(line);
+                }
             }
             if (line != null) {
                 output.println(line);
diff --git 
a/log4j-1.2-api/src/test/java/org/apache/log4j/util/XMLLineAttributeFilter.java 
b/log4j-1.2-api/src/test/java/org/apache/log4j/util/XMLLineAttributeFilter.java
deleted file mode 100644
index 86727f436c..0000000000
--- 
a/log4j-1.2-api/src/test/java/org/apache/log4j/util/XMLLineAttributeFilter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.log4j.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-public class XMLLineAttributeFilter implements Filter {
-
-    Perl5Util util = new Perl5Util();
-
-    @Override
-    public String filter(final String in) {
-        if (util.match("/line=\"\\d{1,3}\"/", in)) {
-            return util.substitute("s/line=\"\\d{1,3}\"/line=\"X\"/", in);
-        } else if (util.match("/line=\"?\"/", in)) {
-            return util.substitute("s/line=\"?\"/line=\"X\"/", in);
-        } else {
-            return in;
-        }
-    }
-}
diff --git 
a/log4j-1.2-api/src/test/java/org/apache/log4j/util/XMLTimestampFilter.java 
b/log4j-1.2-api/src/test/java/org/apache/log4j/util/package-info.java
similarity index 68%
rename from 
log4j-1.2-api/src/test/java/org/apache/log4j/util/XMLTimestampFilter.java
rename to log4j-1.2-api/src/test/java/org/apache/log4j/util/package-info.java
index 6a0fb531c5..ed3ee99b4e 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/XMLTimestampFilter.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/util/package-info.java
@@ -14,19 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+@NullMarked
 package org.apache.log4j.util;
 
-import org.apache.oro.text.perl.Perl5Util;
-
-public class XMLTimestampFilter implements Filter {
-
-    Perl5Util util = new Perl5Util();
-
-    @Override
-    public String filter(final String in) {
-        if (util.match("/timestamp=\"\\d{10,13}\"/", in)) {
-            return 
util.substitute("s/timestamp=\"\\d{10,13}\"/timestamp=\"XXX\"/", in);
-        }
-        return in;
-    }
-}
+import org.jspecify.annotations.NullMarked;
diff --git a/log4j-1.2-api/src/test/resources/hello.vm 
b/log4j-1.2-api/src/test/resources/hello.vm
deleted file mode 100644
index 5ce9755028..0000000000
--- a/log4j-1.2-api/src/test/resources/hello.vm
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>
-<body>
-    #set( $foo = "Velocity" )
-Hello $foo World!
-</body>
-<html>
\ No newline at end of file

Reply via email to