Skip to content

Commit 5f683c6

Browse files
committed
Merge tag 'rel/2.24.1' into 2.x
2 parents 32fb8a4 + 8ee9387 commit 5f683c6

File tree

13 files changed

+165
-39
lines changed

13 files changed

+165
-39
lines changed

log4j-cassandra/pom.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,29 @@
4545
<!-- cassandra-all breaks with a newer version -->
4646
<!-- at least this version has one CVE less than the one suggested by Cassandra -->
4747
<guava.version>25.1-jre</guava.version>
48+
<!-- Pinned transitive dependencies for reproducibility between Linux and MacOS -->
49+
<jnr-ffi.version>2.2.16</jnr-ffi.version>
50+
<snappy.version>1.1.10.7</snappy.version>
4851
</properties>
4952

53+
<dependencyManagement>
54+
<dependencies>
55+
56+
<dependency>
57+
<groupId>com.github.jnr</groupId>
58+
<artifactId>jnr-ffi</artifactId>
59+
<version>${jnr-ffi.version}</version>
60+
</dependency>
61+
62+
<dependency>
63+
<groupId>org.xerial.snappy</groupId>
64+
<artifactId>snappy-java</artifactId>
65+
<version>${snappy.version}</version>
66+
</dependency>
67+
68+
</dependencies>
69+
</dependencyManagement>
70+
5071
<dependencies>
5172
<dependency>
5273
<groupId>org.apache.logging.log4j</groupId>

log4j-core-test/src/test/java/org/apache/logging/log4j/core/util/WatchManagerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.util.concurrent.LinkedBlockingQueue;
3737
import java.util.concurrent.TimeUnit;
3838
import org.apache.logging.log4j.core.config.ConfigurationScheduler;
39+
import org.apache.logging.log4j.core.config.ConfigurationSource;
3940
import org.junit.jupiter.api.AfterEach;
4041
import org.junit.jupiter.api.BeforeEach;
4142
import org.junit.jupiter.api.Test;
@@ -143,10 +144,9 @@ void testWatchManagerResetFile() throws Exception {
143144
*/
144145
@Test
145146
void testWatchManagerCallsWatcher() {
146-
Source source = mock(Source.class);
147147
Watcher watcher = mock(Watcher.class);
148148
when(watcher.isModified()).thenReturn(false);
149-
watchManager.watch(source, watcher);
149+
watchManager.watch(new Source(ConfigurationSource.NULL_SOURCE), watcher);
150150
verify(watcher, timeout(2000)).isModified();
151151
verify(watcher, never()).modified();
152152
when(watcher.isModified()).thenReturn(true);

log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
*/
1717
package org.apache.logging.log4j.core.config;
1818

19-
import static java.util.Objects.requireNonNull;
20-
2119
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2220
import java.io.ByteArrayInputStream;
2321
import java.io.ByteArrayOutputStream;
@@ -34,6 +32,7 @@
3432
import java.net.URLConnection;
3533
import java.nio.file.Files;
3634
import java.nio.file.Path;
35+
import java.util.Objects;
3736
import org.apache.logging.log4j.Logger;
3837
import org.apache.logging.log4j.core.net.UrlConnectionFactory;
3938
import org.apache.logging.log4j.core.util.FileUtils;
@@ -78,7 +77,16 @@ public class ConfigurationSource {
7877
* @param file the file where the input stream originated
7978
*/
8079
public ConfigurationSource(final InputStream stream, final File file) {
81-
this(null, new Source(file), stream, getLastModified(file.toPath()));
80+
this.stream = Objects.requireNonNull(stream, "stream is null");
81+
this.data = null;
82+
this.source = new Source(file);
83+
long modified = 0;
84+
try {
85+
modified = file.lastModified();
86+
} catch (Exception ex) {
87+
// There is a problem with the file. It will be handled somewhere else.
88+
}
89+
this.currentLastModified = this.initialLastModified = modified;
8290
}
8391

8492
/**
@@ -89,16 +97,16 @@ public ConfigurationSource(final InputStream stream, final File file) {
8997
* @param path the path where the input stream originated.
9098
*/
9199
public ConfigurationSource(final InputStream stream, final Path path) {
92-
this(null, new Source(path), stream, getLastModified(path));
93-
}
94-
95-
private static long getLastModified(Path path) {
100+
this.stream = Objects.requireNonNull(stream, "stream is null");
101+
this.data = null;
102+
this.source = new Source(path);
103+
long modified = 0;
96104
try {
97-
return Files.getLastModifiedTime(path).toMillis();
98-
} catch (Exception ignored) {
105+
modified = Files.getLastModifiedTime(path).toMillis();
106+
} catch (Exception ex) {
99107
// There is a problem with the file. It will be handled somewhere else.
100108
}
101-
return 0L;
109+
this.currentLastModified = this.initialLastModified = modified;
102110
}
103111

104112
/**
@@ -120,8 +128,11 @@ public ConfigurationSource(final InputStream stream, final URL url) {
120128
* @param url the URL where the input stream originated
121129
* @param lastModified when the source was last modified.
122130
*/
123-
public ConfigurationSource(InputStream stream, final URL url, final long lastModified) {
124-
this(null, new Source(url), stream, lastModified);
131+
public ConfigurationSource(final InputStream stream, final URL url, final long lastModified) {
132+
this.stream = Objects.requireNonNull(stream, "stream is null");
133+
this.data = null;
134+
this.currentLastModified = this.initialLastModified = lastModified;
135+
this.source = new Source(url);
125136
}
126137

127138
/**
@@ -142,26 +153,19 @@ public ConfigurationSource(InputStream stream) throws IOException {
142153
* @param data data from the source
143154
* @param lastModified when the source was last modified.
144155
*/
145-
public ConfigurationSource(Source source, byte[] data, long lastModified) {
146-
this(data, requireNonNull(source, "source is null"), lastModified);
147-
}
148-
149-
private ConfigurationSource(byte[] data, /*@Nullable*/ Source source, long lastModified) {
150-
this(requireNonNull(data, "data is null"), source, new ByteArrayInputStream(data), lastModified);
156+
public ConfigurationSource(final Source source, final byte[] data, final long lastModified) {
157+
Objects.requireNonNull(source, "source is null");
158+
this.data = Objects.requireNonNull(data, "data is null");
159+
this.stream = new ByteArrayInputStream(data);
160+
this.currentLastModified = this.initialLastModified = lastModified;
161+
this.source = source;
151162
}
152163

153-
/**
154-
* @throws NullPointerException if both {@code stream} and {@code data} are {@code null}.
155-
*/
156-
private ConfigurationSource(
157-
byte /*@Nullable*/[] data, /*@Nullable*/ Source source, InputStream stream, long lastModified) {
158-
if (data == null && source == null) {
159-
throw new NullPointerException("both `data` and `source` are null");
160-
}
161-
this.stream = stream;
162-
this.data = data;
163-
this.source = source;
164+
private ConfigurationSource(final byte[] data, final URL url, final long lastModified) {
165+
this.data = Objects.requireNonNull(data, "data is null");
166+
this.stream = new ByteArrayInputStream(data);
164167
this.currentLastModified = this.initialLastModified = lastModified;
168+
this.source = url == null ? null : new Source(url);
165169
}
166170

167171
/**
@@ -194,6 +198,10 @@ private static byte[] toByteArray(final InputStream inputStream) throws IOExcept
194198
return source == null ? null : source.getFile();
195199
}
196200

201+
private boolean isLocation() {
202+
return source != null && source.getLocation() != null;
203+
}
204+
197205
/**
198206
* Returns the configuration source URL, or {@code null} if this configuration source is based on a file or has
199207
* neither a file nor an URL.
@@ -279,13 +287,13 @@ public InputStream getInputStream() {
279287
URL url = getURL();
280288
if (url != null && data != null) {
281289
// Creates a ConfigurationSource without accessing the URL since the data was provided.
282-
return new ConfigurationSource(data, new Source(url), currentLastModified);
290+
return new ConfigurationSource(data, url, currentLastModified);
283291
}
284292
URI uri = getURI();
285293
if (uri != null) {
286294
return fromUri(uri);
287295
}
288-
return data == null ? null : new ConfigurationSource(data, null, currentLastModified);
296+
return data != null ? new ConfigurationSource(data, null, currentLastModified) : null;
289297
}
290298

291299
@Override

log4j-mongodb/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<!-- OSGi and JPMS options -->
3131
<Fragment-Host>org.apache.logging.log4j.core</Fragment-Host>
3232
<!-- Dependency versions -->
33-
<mongodb.version>5.1.3</mongodb.version>
33+
<mongodb.version>5.1.4</mongodb.version>
3434
<slf4j2.version>2.0.16</slf4j2.version>
3535
</properties>
3636
<dependencyManagement>

pom.xml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,10 @@
307307

308308
<!-- project version -->
309309
<revision>2.25.0-SNAPSHOT</revision>
310+
<!-- Versions used on the site: no snapshots! -->
311+
<site-log4j-api.version>2.24.1</site-log4j-api.version>
312+
<site-log4j-core.version>2.24.1</site-log4j-core.version>
313+
<site-log4j-layout-template-json.version>2.24.1</site-log4j-layout-template-json.version>
310314

311315
<!-- =================
312316
Common properties
@@ -320,7 +324,7 @@
320324
2. This value is employed in various places while creating the distribution
321325
To mitigate these, we define a *dummy* value here and let the CI replace it during a release.
322326
Hence, *DO NOT MANUALLY EDIT THIS VALUE*! -->
323-
<project.build.outputTimestamp>2024-09-03T16:00:23Z</project.build.outputTimestamp>
327+
<project.build.outputTimestamp>2024-09-24T13:33:09Z</project.build.outputTimestamp>
324328

325329
<!-- ========================
326330
Site-specific properties
@@ -347,10 +351,7 @@
347351
<site-je.version>18.3.12</site-je.version>
348352
<site-jeromq.version>0.6.0</site-jeromq.version>
349353
<site-kafka.version>3.8.0</site-kafka.version>
350-
<site-log4j-api.version>2.24.0</site-log4j-api.version>
351-
<site-log4j-core.version>2.24.0</site-log4j-core.version>
352-
<site-log4j-layout-template-json.version>2.24.0</site-log4j-layout-template-json.version>
353-
<site-logback.version>1.4.0</site-logback.version>
354+
<site-logback.version>1.5.5</site-logback.version>
354355
<site-slf4j.version>2.0.16</site-slf4j.version>
355356

356357
<!-- =====================================================
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
////
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
////
17+
18+
[#release-notes-${release.version?replace("[^a-zA-Z0-9]", "-", "r")}]
19+
== ${release.version}
20+
21+
<#if release.date?has_content>Release date:: ${release.date}</#if>
22+
23+
This release contains mainly bug fixes of problems encountered with the thread context map, logger registry and configuration reloading.
24+
25+
It also enhances integration tests to use Docker images of the most recent releases of MongoDB and Elastic Search.
26+
27+
<#include "../.changelog.adoc.ftl">

src/changelog/2.24.1/.release.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one or more
4+
~ contributor license agreements. See the NOTICE file distributed with
5+
~ this work for additional information regarding copyright ownership.
6+
~ The ASF licenses this file to you under the Apache License, Version 2.0
7+
~ (the "License"); you may not use this file except in compliance with
8+
~ the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
-->
18+
<release xmlns="https://logging.apache.org/xml/ns"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
21+
date="2024-09-24" version="2.24.1"/>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="https://logging.apache.org/xml/ns"
4+
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
5+
type="fixed">
6+
<issue id="2229" link="https://github.com/apache/logging-log4j2/issues/2229"/>
7+
<description format="asciidoc">Switch MongoDB tests to use Docker.</description>
8+
</entry>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="https://logging.apache.org/xml/ns"
4+
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
5+
type="changed">
6+
<issue id="2936" link="https://github.com/apache/logging-log4j2/pull/2936"/>
7+
<description format="asciidoc">Rework `LoggerRegistry` to make it `MessageFactory`-namespaced.
8+
This effectively allows loggers of same name, but different message factory.</description>
9+
</entry>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="https://logging.apache.org/xml/ns"
4+
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
5+
type="fixed">
6+
<issue id="2937" link="https://github.com/apache/logging-log4j2/issues/2937"/>
7+
<description format="asciidoc">Fix reloading of the configuration from an HTTP(S) source</description>
8+
</entry>

0 commit comments

Comments
 (0)