Skip to content

Commit cb46e63

Browse files
authored
Uniformize API of StackLocator versions (#3340)
The Java 9 version of `StackLocator` has an additional public `getCallerClass(String)` method. This method makes the Java 8 and 9 versions of `StackLocator` expose different APIs to the user. To prevent API compatibility problems, we remove the additional method. This incompatibility was accidentally discovered during the work in #3339: `japicmp` did randomly compare a `StackLocator` class from the old version with a `StackLocator` class from the new version. This is part of #1867.
1 parent eb4f792 commit cb46e63

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

log4j-api-java9/src/main/java/org/apache/logging/log4j/util/StackLocator.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ public Class<?> getCallerClass(final Class<?> sentinelClass, final Predicate<Cla
5353
.orElse(null));
5454
}
5555

56-
public Class<?> getCallerClass(final String fqcn) {
57-
return getCallerClass(fqcn, "");
58-
}
59-
6056
public Class<?> getCallerClass(final String fqcn, final String pkg) {
6157
return WALKER.walk(s -> s.dropWhile(f -> !f.getClassName().equals(fqcn))
6258
.dropWhile(f -> f.getClassName().equals(fqcn))

log4j-api-java9/src/test/java/org/apache/logging/log4j/util/java9/StackLocatorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private static class Inner {
7373
private static void assertCallerClassViaName() {
7474
final Class<?> expected = StackLocatorTest.class;
7575
final StackLocator stackLocator = StackLocator.getInstance();
76-
final Class<?> actual = stackLocator.getCallerClass(Inner.class.getName());
76+
final Class<?> actual = stackLocator.getCallerClass(Inner.class.getName(), "");
7777
assertSame(expected, actual);
7878
}
7979

0 commit comments

Comments
 (0)