You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by vy...@apache.org on 2023/12/06 13:51:30 UTC
(logging-log4j2) 02/03: Fix `Log4j2EventListenerTest`
This is an automated email from the ASF dual-hosted git repository.
vy pushed a commit to branch main-spring-cloud-revamp
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit e2641a8fcdfbbdf2fd68e544d34803b8a5477f40
Author: Volkan Yazıcı <vo...@yazi.ci>
AuthorDate: Wed Dec 6 14:47:24 2023 +0100
Fix `Log4j2EventListenerTest`
---
.../log4j/core/config/ConfigurationFactory.java | 5 +++
.../log4j/core/net/UrlConnectionFactory.java | 10 ++++++
log4j-spring-cloud-config-client/pom.xml | 38 ++++------------------
.../config/client/Log4j2EventListenerTest.java | 3 --
4 files changed, 21 insertions(+), 35 deletions(-)
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
index 0898b7a98f..493638450f 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
@@ -121,6 +121,11 @@ public abstract class ConfigurationFactory extends ConfigurationBuilderFactory {
return true;
}
+ @Deprecated(since = "3.0.0", forRemoval = true)
+ public static ConfigurationFactory getInstance() {
+ return LoggerContext.getContext(false).getInstanceFactory().getInstance(KEY);
+ }
+
/**
* Required for Spring Boot.
* @param props PropertiesUtil.
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/UrlConnectionFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/UrlConnectionFactory.java
index 4093e23377..50c724de99 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/UrlConnectionFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/UrlConnectionFactory.java
@@ -56,6 +56,16 @@ public class UrlConnectionFactory {
private static final String NO_PROTOCOLS = "_none";
public static final String ALLOWED_PROTOCOLS = "log4j2.Configuration.allowedProtocols";
+ @Deprecated(since = "3.0.0", forRemoval = true)
+ public static <T extends URLConnection> T createConnection(
+ final URL url,
+ final long lastModifiedMillis,
+ final SslConfiguration sslConfiguration,
+ final AuthorizationProvider authorizationProvider)
+ throws IOException {
+ return createConnection(url, lastModifiedMillis, sslConfiguration, authorizationProvider, PropertiesUtil.getProperties());
+ }
+
@SuppressFBWarnings(
value = "URLCONNECTION_SSRF_FD",
justification = "The URL parameter originates only from secure sources.")
diff --git a/log4j-spring-cloud-config-client/pom.xml b/log4j-spring-cloud-config-client/pom.xml
index bfdcca6b32..6d6594c041 100644
--- a/log4j-spring-cloud-config-client/pom.xml
+++ b/log4j-spring-cloud-config-client/pom.xml
@@ -46,7 +46,7 @@
<!-- dependency versions -->
<spring-boot.version>3.2.0</spring-boot.version>
- <spring-cloud.version>2021.0.8</spring-cloud.version>
+ <spring-cloud.version>2022.0.4</spring-cloud.version>
</properties>
@@ -86,31 +86,11 @@
<dependencies>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- </dependency>
-
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-spring-boot</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-bus</artifactId>
- </dependency>
-
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
@@ -128,26 +108,20 @@
</dependency>
<dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
+ <groupId>org.junit.vintage</groupId>
+ <artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
+ <artifactId>spring-boot-starter-log4j2</artifactId>
<scope>test</scope>
</dependency>
diff --git a/log4j-spring-cloud-config-client/src/test/java/org/apache/logging/log4j/spring/cloud/config/client/Log4j2EventListenerTest.java b/log4j-spring-cloud-config-client/src/test/java/org/apache/logging/log4j/spring/cloud/config/client/Log4j2EventListenerTest.java
index 22108c9459..65512cf72c 100644
--- a/log4j-spring-cloud-config-client/src/test/java/org/apache/logging/log4j/spring/cloud/config/client/Log4j2EventListenerTest.java
+++ b/log4j-spring-cloud-config-client/src/test/java/org/apache/logging/log4j/spring/cloud/config/client/Log4j2EventListenerTest.java
@@ -27,7 +27,6 @@ import org.apache.logging.log4j.core.config.Reconfigurable;
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
import org.apache.logging.log4j.core.util.Source;
import org.apache.logging.log4j.core.util.Watcher;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.RuleChain;
@@ -41,8 +40,6 @@ import org.springframework.test.context.junit4.SpringRunner;
/**
* Class Description goes here.
*/
-@Ignore(
- "Fails with `java.lang.NoClassDefFoundError: org/apache/logging/log4j/internal/LogManagerStatus` since `log4j-spring-boot` of `2.x` is injected due to Spring Boot 2 BOM import. Spring Boot must be updated from version 2 to 3. (#2018)")
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {SpringConfiguration.class})
public class Log4j2EventListenerTest {