Skip to content

Commit 4f89455

Browse files
committed
Remove obsolete logging test
This commit removes a logging test that is now obsolete. This test was added when we included a forked version of some Log4j 2 classes to workaround a bug in Log4j 2. This bug was fixed and a version of Log4j 2 incorporating this fix was previously integrated into Elaticsearch. At that time, the forked versions were removed, and this test should have been removed with it.
1 parent d675146 commit 4f89455

File tree

1 file changed

+0
-40
lines changed

1 file changed

+0
-40
lines changed

qa/evil-tests/src/test/java/org/elasticsearch/common/logging/EvilLoggerTests.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -141,46 +141,6 @@ public void testPrefixLogger() throws IOException, IllegalAccessException, UserE
141141
}
142142
}
143143

144-
145-
public void testLog4jShutdownHack() {
146-
final AtomicBoolean denied = new AtomicBoolean();
147-
final SecurityManager sm = System.getSecurityManager();
148-
try {
149-
System.setSecurityManager(new SecurityManager() {
150-
@Override
151-
public void checkPermission(Permission perm) {
152-
// just grant all permissions to Log4j, except we deny MBeanServerPermission
153-
// "createMBeanServer" as this will trigger the Log4j bug
154-
if (perm instanceof MBeanServerPermission && "createMBeanServer".equals(perm.getName())) {
155-
// without the hack in place, Log4j will try to get an MBean server which we will deny
156-
// with the hack in place, this permission should never be requested by Log4j
157-
denied.set(true);
158-
throw new AccessControlException("denied");
159-
}
160-
}
161-
162-
@Override
163-
public void checkPropertyAccess(String key) {
164-
/*
165-
* grant access to all properties; this is so that Log4j can check if its usage
166-
* of JMX is disabled or not by reading log4j2.disable.jmx but there are other
167-
* properties that Log4j will try to read as well and its simpler to just grant
168-
* them all
169-
*/
170-
}
171-
});
172-
173-
// this will trigger the bug without the hack
174-
LoggerContext context = (LoggerContext) LogManager.getContext(false);
175-
Configurator.shutdown(context);
176-
177-
// Log4j should have never requested permissions to create an MBean server
178-
assertFalse(denied.get());
179-
} finally {
180-
System.setSecurityManager(sm);
181-
}
182-
}
183-
184144
private void setupLogging(final String config) throws IOException, UserException {
185145
final Path configDir = getDataPath(config);
186146
// need to set custom path.conf so we can use a custom log4j2.properties file for the test

0 commit comments

Comments
 (0)