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

Defer initialization of RabbitTemplate until the LogAdapter.Log4jLog is initialized #1148

Closed
garyrussell opened this issue Jan 27, 2020 · 1 comment · Fixed by #1149 or #1154
Closed
Assignees
Labels
backport:2.1.x (obsolete) status: on-hold-dependency Waiting for a fix to a dependent project
Milestone

Comments

@garyrussell
Copy link
Contributor

See spring-projects/spring-amqp-samples#59

@garyrussell garyrussell self-assigned this Jan 27, 2020
@garyrussell garyrussell added this to the 2.2.4 milestone Jan 27, 2020
garyrussell added a commit to garyrussell/spring-amqp that referenced this issue Jan 27, 2020
Resolves spring-projects/spring-amqp-samples#59

Defer creation of all Spring static loggers from appender until the
appender is initialized.

The first logger (e.g. Spring Boot) intializes the static `LoggerContext`
field in `LogAdapter.Log4jLog`; this, in turn initializes the appender.

However, the appender references Spring objects that have static loggers.
This causes the `Log4jLog` CTOR to be called before the field is initialized,
causing an NPE.

Defer creation of all static loggers until the appender is fully initialized.

Tested with the log4j2 sample app.
garyrussell added a commit to garyrussell/spring-amqp that referenced this issue Jan 27, 2020
Resolves spring-projects/spring-amqp-samples#59

Defer creation of all Spring static loggers from appender until the
appender is initialized.

The first logger (e.g. Spring Boot) intializes the static `LoggerContext`
field in `LogAdapter.Log4jLog`; this, in turn initializes the appender.

However, the appender references Spring objects that have static loggers.
This causes the `Log4jLog` CTOR to be called before the field is initialized,
causing an NPE.

Defer creation of all static loggers until the appender is fully initialized.

Tested with the log4j2 sample app.

**cherry-pick to 2.1.x**
garyrussell added a commit to garyrussell/spring-amqp that referenced this issue Jan 27, 2020
Resolves spring-projects/spring-amqp-samples#59

Defer creation of all Spring static loggers from appender until the
appender is initialized.

The first logger (e.g. Spring Boot) initializes the static `LoggerContext`
field in `LogAdapter.Log4jLog`; this, in turn initializes the appender.

However, the appender references Spring objects that have static loggers.
This causes the `Log4jLog` CTOR to be called before the field is initialized,
causing an NPE.

Defer creation of all static loggers until the appender is fully initialized.

Tested with the log4j2 sample app.

Also add a test for async sends.

**cherry-pick to 2.1.x**
garyrussell added a commit to garyrussell/spring-amqp that referenced this issue Jan 27, 2020
Resolves spring-projects#1148

Defer creation of all Spring static loggers from appender until the
appender is initialized.

The first logger (e.g. Spring Boot) initializes the static `LoggerContext`
field in `LogAdapter.Log4jLog`; this, in turn initializes the appender.

However, the appender references Spring objects that have static loggers.
This causes the `Log4jLog` CTOR to be called before the field is initialized,
causing an NPE.

Defer creation of all static loggers until the appender is fully initialized.

Tested with the log4j2 sample app.

Also add a test for async sends.

**cherry-pick to 2.1.x**
artembilan pushed a commit that referenced this issue Jan 27, 2020
Resolves #1148

Defer creation of all Spring static loggers from appender until the
appender is initialized.

The first logger (e.g. Spring Boot) initializes the static `LoggerContext`
field in `LogAdapter.Log4jLog`; this, in turn initializes the appender.

However, the appender references Spring objects that have static loggers.
This causes the `Log4jLog` CTOR to be called before the field is initialized,
causing an NPE.

Defer creation of all static loggers until the appender is fully initialized.

Tested with the log4j2 sample app.

Also add a test for async sends.

**cherry-pick to 2.1.x**

* NOSONAR - inconsistent sync
garyrussell added a commit that referenced this issue Jan 27, 2020
Resolves #1148

Defer creation of all Spring static loggers from appender until the
appender is initialized.

The first logger (e.g. Spring Boot) initializes the static `LoggerContext`
field in `LogAdapter.Log4jLog`; this, in turn initializes the appender.

However, the appender references Spring objects that have static loggers.
This causes the `Log4jLog` CTOR to be called before the field is initialized,
causing an NPE.

Defer creation of all static loggers until the appender is fully initialized.

Tested with the log4j2 sample app.

Also add a test for async sends.

**cherry-pick to 2.1.x**

* NOSONAR - inconsistent sync
@garyrussell
Copy link
Contributor Author

We will be able to revert this change with a change to Spring Framework. See spring-projects/spring-framework#24440

@garyrussell garyrussell reopened this Jan 28, 2020
@garyrussell garyrussell added the status: on-hold-dependency Waiting for a fix to a dependent project label Jan 28, 2020
garyrussell added a commit to garyrussell/spring-amqp that referenced this issue Jan 31, 2020
garyrussell added a commit to garyrussell/spring-amqp that referenced this issue Jan 31, 2020
artembilan pushed a commit that referenced this issue Jan 31, 2020
Resolves #1148

Fix is now in Spring Framework.
artembilan pushed a commit that referenced this issue Jan 31, 2020
Resolves #1148

Fix is now in Spring Framework.
garyrussell added a commit that referenced this issue Feb 12, 2020
garyrussell added a commit that referenced this issue Feb 25, 2020
Resolves #1162

Revert "Revert "GH-1148: Revert Log4j Appender Change""

This reverts commit 7af0f90.

Upgrade SF to 5.2.4.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:2.1.x (obsolete) status: on-hold-dependency Waiting for a fix to a dependent project
Projects
None yet
1 participant