Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set log4j2.is.webapp to false if not set so that shutdown hooks are run #12056

Merged
merged 6 commits into from
Dec 11, 2021

Conversation

clintropolis
Copy link
Member

After updating in log4j2 in #12051, errors when shutting down services and tasks appear of the form

org.apache.druid.initialization.Log4jShutterDownerModule$Log4jShutterDowner.stop()] on object[org.apache.druid.initialization.Log4jShutterDownerModule$Log4jShutterDowner@ad5cffa]
java.lang.reflect.InvocationTargetException: null
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_292]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_292]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_292]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_292]
	at org.apache.druid.java.util.common.lifecycle.Lifecycle$AnnotationBasedHandler.stop(Lifecycle.java:465) [druid-core-0.22.1.jar:0.22.1]
	at org.apache.druid.java.util.common.lifecycle.Lifecycle.stop(Lifecycle.java:368) [druid-core-0.22.1.jar:0.22.1]
	at org.apache.druid.cli.CliPeon.run(CliPeon.java:323) [druid-services-0.22.1.jar:0.22.1]
	at org.apache.druid.cli.Main.main(Main.java:113) [druid-services-0.22.1.jar:0.22.1]
Caused by: org.apache.druid.java.util.common.ISE: Expected state [STARTED] found [INITIALIZED]
	at org.apache.druid.common.config.Log4jShutdown.stop(Log4jShutdown.java:105) ~[druid-core-0.22.1.jar:0.22.1]
	at org.apache.druid.initialization.Log4jShutterDownerModule$Log4jShutterDowner.stop(Log4jShutterDownerModule.java:116) ~[druid-server-0.22.1.jar:0.22.1]
	... 8 more

and shutdown hooks are not run.

This is because by default log4j2.is.webapp is set to true if it detects javax.servlet.Servlet or jakarta.servlet.Servlet on the classpath, and shutdown hooks are disabled for web-apps in apache/logging-log4j2@b59819e

This PR makes shutdown hooks work again by automatically setting this to false if it is not explicitly set in system properties (similar to the shutdown hook properties themselves). I don't think this should have any impact on Druid since we are not technically a web app, and this setting only appears to be used by a few jmx related settings.

@jihoonson jihoonson added this to the 0.22.1 milestone Dec 11, 2021
@jihoonson jihoonson added the Bug label Dec 11, 2021
@clintropolis clintropolis merged commit e53c3e8 into apache:master Dec 11, 2021
@clintropolis clintropolis deleted the fix-log4j2-shutdown-hooks branch December 11, 2021 05:55
nikhil-ddu pushed a commit to twitter-forks/druid that referenced this pull request Dec 13, 2021
…un (apache#12056)

* set log4j2.is.webapp to false if not set so that shutdown hooks are run
nikhil-ddu pushed a commit to twitter-forks/druid that referenced this pull request Dec 13, 2021
…un (apache#12056)

* set log4j2.is.webapp to false if not set so that shutdown hooks are run
CodingParsley pushed a commit to confluentinc/druid that referenced this pull request Jan 24, 2022
…un (apache#12056)

* set log4j2.is.webapp to false if not set so that shutdown hooks are run
CodingParsley added a commit to confluentinc/druid that referenced this pull request Jan 24, 2022
…un (apache#12056) (#65)

* set log4j2.is.webapp to false if not set so that shutdown hooks are run

Co-authored-by: Clint Wylie <cwylie@apache.org>
debasatwa29 pushed a commit to debasatwa29/druid that referenced this pull request Jun 2, 2022
…ilities

Summary:
Druid is running with JVM 1.8.0_232 but log4j 2.5 so it's P1 rather than p0.

Pull upstream to upgrade log4j to 2.15.0 to address security vulnerabilities

Changes are from the following upstream PRs:

# Upgrade log4j from 2.8.2 to 2.15.0
apache#12051
apache#12056

# Upgrade log4j from 2.5 to 2.8.2
apache#8878

Reviewers: O1139 Druid, jgu, itallam

Reviewed By: O1139 Druid, jgu, itallam

Subscribers: jenkins, shawncao, #realtime-analytics

Differential Revision: https://phabricator.pinadmin.com/D823708
anishanagarajan pushed a commit to twitter-forks/druid that referenced this pull request Sep 23, 2022
…un (apache#12056)

* set log4j2.is.webapp to false if not set so that shutdown hooks are run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants