Skip to content

Commit c52a82f

Browse files
committed
fix: patch reload4j for Kafka 3.9.x
1 parent ff55b16 commit c52a82f

File tree

7 files changed

+75
-1
lines changed

7 files changed

+75
-1
lines changed

kafka/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
FROM local-image/kafka/kcat AS kcat
55
FROM local-image/kafka/kafka-opa-plugin AS kafka-opa-plugin
6-
6+
FROM local-image/shared/reload4j AS patched-reload4j
77
FROM local-image/java-devel AS kafka-builder
88

99
ARG PRODUCT_VERSION
@@ -18,8 +18,12 @@ WORKDIR /stackable
1818
COPY --chown=${STACKABLE_USER_UID}:0 kafka/stackable/jmx/ /stackable/jmx/
1919
COPY --chown=${STACKABLE_USER_UID}:0 kafka/stackable/patches/patchable.toml /stackable/src/kafka/stackable/patches/patchable.toml
2020
COPY --chown=${STACKABLE_USER_UID}:0 kafka/stackable/patches/${PRODUCT_VERSION} /stackable/src/kafka/stackable/patches/${PRODUCT_VERSION}
21+
COPY --chown=${STACKABLE_USER_UID}:0 --from=patched-reload4j /stackable/.m2/repository /stackable/patched-reload4j-libs
2122

2223
RUN <<EOF
24+
mkdir -p /stackable/.m2/repository
25+
cp -r /stackable/patched-reload4j-libs/* /stackable/.m2/repository
26+
2327
cd "$(/stackable/patchable --images-repo-root=src checkout kafka ${PRODUCT_VERSION})"
2428

2529
NEW_VERSION="${PRODUCT_VERSION}-stackable${RELEASE_VERSION}"
@@ -78,6 +82,7 @@ COPY --chown=${STACKABLE_USER_UID}:0 --from=kcat /stackable/kcat-${KAFKA_KCAT_VE
7882
COPY --chown=${STACKABLE_USER_UID}:0 --from=kcat /licenses /licenses
7983
COPY --chown=${STACKABLE_USER_UID}:0 --from=kafka-opa-plugin /stackable/src/kafka/kafka-opa-plugin/patchable-work/worktree/${KAFKA_KAFKA_OPA_PLUGIN_VERSION}/build/libs/opa-authorizer-${KAFKA_KAFKA_OPA_PLUGIN_VERSION}-all.jar /stackable/kafka_${SCALA_VERSION}-${PRODUCT_VERSION}-stackable${RELEASE_VERSION}/libs/opa-authorizer-${KAFKA_KAFKA_OPA_PLUGIN_VERSION}-all.jar
8084
COPY --chown=${STACKABLE_USER_UID}:0 --from=kafka-opa-plugin /stackable/kafka-opa-plugin-${KAFKA_KAFKA_OPA_PLUGIN_VERSION}-src.tar.gz /stackable
85+
COPY --chown=${STACKABLE_USER_UID}:0 --from=patched-reload4j /stackable/*-src.tar.gz /stackable
8186

8287
COPY --chown=${STACKABLE_USER_UID}:0 kafka/licenses /licenses
8388

kafka/boil-config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ java-base = "21"
33
java-devel = "21"
44
"kafka/kcat" = "1.7.0"
55
"kafka/kafka-opa-plugin" = "1.5.1"
6+
"shared/reload4j" = "1.2.25"
67

78
[versions."3.7.2".build-arguments]
89
scala-version = "2.13"
@@ -13,6 +14,7 @@ java-base = "21"
1314
java-devel = "21"
1415
"kafka/kcat" = "1.7.0"
1516
"kafka/kafka-opa-plugin" = "1.5.1"
17+
"shared/reload4j" = "1.2.25"
1618

1719
[versions."3.9.1".build-arguments]
1820
scala-version = "2.13"

shared/reload4j/Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# syntax=docker/dockerfile:1.15.1@sha256:9857836c9ee4268391bb5b09f9f157f3c91bb15821bb77969642813b0d00518d
2+
# check=error=true
3+
4+
FROM local-image/java-devel AS builder
5+
6+
ARG PRODUCT_VERSION
7+
ARG RELEASE_VERSION
8+
ARG STACKABLE_USER_UID
9+
10+
COPY --chown=${STACKABLE_USER_UID}:0 shared/reload4j/stackable/patches/patchable.toml /stackable/src/shared/reload4j/stackable/patches/patchable.toml
11+
COPY --chown=${STACKABLE_USER_UID}:0 shared/reload4j/stackable/patches/${PRODUCT_VERSION} /stackable/src/shared/reload4j/stackable/patches/${PRODUCT_VERSION}
12+
13+
USER ${STACKABLE_USER_UID}
14+
WORKDIR /stackable
15+
16+
RUN <<EOF
17+
cd "$(/stackable/patchable --images-repo-root=src checkout shared/reload4j ${PRODUCT_VERSION})"
18+
19+
# Create snapshot of the source code including custom patches
20+
tar -czf /stackable/reload4j-${PRODUCT_VERSION}-src.tar.gz .
21+
22+
mvn --batch-mode --no-transfer-progress clean install -DskipTests -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
23+
EOF

shared/reload4j/boil-config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[versions."1.2.25".local-images]
2+
java-devel = "8"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From 3c1ce68a548f435b63a104537b8653e5f14347a7 Mon Sep 17 00:00:00 2001
2+
From: Razvan-Daniel Mihai <[email protected]>
3+
Date: Wed, 5 Nov 2025 12:27:34 +0100
4+
Subject: fix: move StringBuffer into function to prevent race
5+
6+
---
7+
src/main/java/org/apache/log4j/xml/XMLLayout.java | 10 +---------
8+
1 file changed, 1 insertion(+), 9 deletions(-)
9+
10+
diff --git a/src/main/java/org/apache/log4j/xml/XMLLayout.java b/src/main/java/org/apache/log4j/xml/XMLLayout.java
11+
index 4f0d99f3..157ecdc6 100644
12+
--- a/src/main/java/org/apache/log4j/xml/XMLLayout.java
13+
+++ b/src/main/java/org/apache/log4j/xml/XMLLayout.java
14+
@@ -64,9 +64,7 @@ import java.util.Arrays;
15+
public class XMLLayout extends Layout {
16+
17+
private final int DEFAULT_SIZE = 256;
18+
- private final int UPPER_LIMIT = 2048;
19+
20+
- private StringBuffer buf = new StringBuffer(DEFAULT_SIZE);
21+
private boolean locationInfo = false;
22+
private boolean properties = false;
23+
24+
@@ -121,13 +119,7 @@ public class XMLLayout extends Layout {
25+
*/
26+
public String format(final LoggingEvent event) {
27+
28+
- // Reset working buffer. If the buffer is too large, then we need a new
29+
- // one in order to avoid the penalty of creating a large array.
30+
- if (buf.capacity() > UPPER_LIMIT) {
31+
- buf = new StringBuffer(DEFAULT_SIZE);
32+
- } else {
33+
- buf.setLength(0);
34+
- }
35+
+ StringBuffer buf = new StringBuffer(DEFAULT_SIZE);
36+
37+
// We yield to the \r\n heresy.
38+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mirror = "https://github.com/stackabletech/reload4j.git"
2+
base = "2dfce6aac8e9881f60b6c9fda3fdc1e79e2c14b3"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
upstream = "https://github.com/qos-ch/reload4j.git"
2+
default-mirror = "https://github.com/stackabletech/reload4j.git"

0 commit comments

Comments
 (0)