Skip to content

Commit 2c2b612

Browse files
authored
fix: logback fix for Zookeeper with patched version (#1320)
* fix zookeeper logback libs with patched version * changelog
1 parent ff4ff04 commit 2c2b612

File tree

8 files changed

+99
-0
lines changed

8 files changed

+99
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ All notable changes to this project will be documented in this file.
5454
- superset: Fix the 4.1.2 build when building from source ([#1309])
5555
- superset: Pin `luxon` to version 3.6.1 to fix build ([#1315], [#1316])
5656
- nifi: Use a patched version of logback to fix corrupted logs ([#1314])
57+
- zookeeper: Use a patched version of logback to fix corrupted logs ([#1320])
5758

5859
### Fixed
5960

@@ -117,6 +118,7 @@ All notable changes to this project will be documented in this file.
117118
[#1316]: https://github.com/stackabletech/docker-images/pull/1316
118119
[#1318]: https://github.com/stackabletech/docker-images/pull/1318
119120
[#1319]: https://github.com/stackabletech/docker-images/pull/1319
121+
[#1320]: https://github.com/stackabletech/docker-images/pull/1320
120122

121123
## [25.7.0] - 2025-07-23
122124

shared/logback/boil-config.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
[versions."1.2.13".local-images]
2+
java-devel = "8"
3+
14
[versions."1.3.14".local-images]
25
java-devel = "21"
36

7+
[versions."1.3.15".local-images]
8+
java-devel = "21"
9+
410
[versions."1.5.18".local-images]
511
java-devel = "21"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From 2f94a71b44275028e99fcf4f7540ae694a1d68c7 Mon Sep 17 00:00:00 2001
2+
From: Andrew Kenworthy <[email protected]>
3+
Date: Mon, 27 Oct 2025 15:58:12 +0100
4+
Subject: fix: move StringBuilder into function to prevent race
5+
6+
---
7+
.../java/ch/qos/logback/classic/log4j/XMLLayout.java | 10 +---------
8+
1 file changed, 1 insertion(+), 9 deletions(-)
9+
10+
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java b/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java
11+
index ee640eeb6..edda3e9fb 100644
12+
--- a/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java
13+
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java
14+
@@ -38,9 +38,7 @@ import ch.qos.logback.core.helpers.Transform;
15+
public class XMLLayout extends LayoutBase<ILoggingEvent> {
16+
17+
private final int DEFAULT_SIZE = 256;
18+
- private final int UPPER_LIMIT = 2048;
19+
20+
- private StringBuilder buf = new StringBuilder(DEFAULT_SIZE);
21+
private boolean locationInfo = false;
22+
private boolean properties = false;
23+
24+
@@ -96,13 +94,7 @@ public class XMLLayout extends LayoutBase<ILoggingEvent> {
25+
*/
26+
public String doLayout(ILoggingEvent 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 StringBuilder(DEFAULT_SIZE);
32+
- } else {
33+
- buf.setLength(0);
34+
- }
35+
+ StringBuilder buf = new StringBuilder(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/logback.git"
2+
base = "2648b9e7fbb47426c89b9c93b411c07484e8f277"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From afa8af8c6574806e2482063a301130562a8f2b0d Mon Sep 17 00:00:00 2001
2+
From: Andrew Kenworthy <[email protected]>
3+
Date: Mon, 27 Oct 2025 16:00:59 +0100
4+
Subject: fix: move StringBuilder into function to prevent race
5+
6+
---
7+
.../java/ch/qos/logback/classic/log4j/XMLLayout.java | 10 +---------
8+
1 file changed, 1 insertion(+), 9 deletions(-)
9+
10+
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java b/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java
11+
index 4bc04388a..405f4ef26 100644
12+
--- a/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java
13+
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/log4j/XMLLayout.java
14+
@@ -38,9 +38,7 @@ import ch.qos.logback.core.helpers.Transform;
15+
public class XMLLayout extends LayoutBase<ILoggingEvent> {
16+
17+
private final int DEFAULT_SIZE = 256;
18+
- private final int UPPER_LIMIT = 2048;
19+
20+
- private StringBuilder buf = new StringBuilder(DEFAULT_SIZE);
21+
private boolean locationInfo = false;
22+
private boolean properties = false;
23+
24+
@@ -96,13 +94,7 @@ public class XMLLayout extends LayoutBase<ILoggingEvent> {
25+
*/
26+
public String doLayout(ILoggingEvent 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 StringBuilder(DEFAULT_SIZE);
32+
- } else {
33+
- buf.setLength(0);
34+
- }
35+
+ StringBuilder buf = new StringBuilder(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/logback.git"
2+
base = "81f8c25e2a2fae99f45029c27dc793bdaa8cb079"

zookeeper/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# ==============================================================================
55
# START ZOOKEEPER BUILDER
66

7+
FROM local-image/shared/logback AS patched-logback
8+
79
FROM local-image/java-devel AS builder
810

911
ARG PRODUCT_VERSION
@@ -16,12 +18,16 @@ COPY --chown=${STACKABLE_USER_UID}:0 zookeeper/stackable/patches/patchable.toml
1618
COPY --chown=${STACKABLE_USER_UID}:0 zookeeper/stackable/patches/${PRODUCT_VERSION} /stackable/src/zookeeper/stackable/patches/${PRODUCT_VERSION}
1719
# Copy JMX config into the builder
1820
COPY --chown=${STACKABLE_USER_UID}:0 zookeeper/stackable/jmx /stackable/jmx
21+
COPY --chown=${STACKABLE_USER_UID}:0 --from=patched-logback /stackable/.m2/repository /stackable/patched-logback-libs
1922

2023
USER ${STACKABLE_USER_UID}
2124
WORKDIR /stackable
2225

2326
# Download ZooKeeper sources from our own repo
2427
RUN <<EOF
28+
mkdir -p /stackable/.m2/repository
29+
cp -r /stackable/patched-logback-libs/* /stackable/.m2/repository
30+
2531
cd "$(/stackable/patchable --images-repo-root=src checkout zookeeper ${PRODUCT_VERSION})"
2632

2733
ORIGINAL_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
@@ -84,6 +90,8 @@ LABEL \
8490
COPY --chown=${STACKABLE_USER_UID}:0 --from=builder /stackable/apache-zookeeper-${PRODUCT_VERSION}-stackable${RELEASE_VERSION}-bin /stackable/apache-zookeeper-${PRODUCT_VERSION}-stackable${RELEASE_VERSION}-bin/
8591
COPY --chown=${STACKABLE_USER_UID}:0 --from=builder /stackable/zookeeper-${PRODUCT_VERSION}-stackable${RELEASE_VERSION}-src.tar.gz /stackable
8692
COPY --chown=${STACKABLE_USER_UID}:0 --from=builder /stackable/jmx /stackable/jmx/
93+
# Copy over the patched logback files
94+
COPY --chown=${STACKABLE_USER_UID}:0 --from=patched-logback /stackable/*-src.tar.gz /stackable
8795
COPY zookeeper/licenses /licenses
8896

8997
RUN <<EOF
@@ -102,6 +110,7 @@ chown -h ${STACKABLE_USER_UID}:0 /stackable/zookeeper
102110
# fix missing permissions
103111
chmod g=u /stackable/jmx
104112
chmod g=u /stackable/apache-zookeeper-${PRODUCT_VERSION}-stackable${RELEASE_VERSION}-bin/
113+
chmod g=u /stackable/*-src.tar.gz
105114
EOF
106115

107116
# ----------------------------------------

zookeeper/boil-config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
[versions."3.9.3".local-images]
22
java-base = "17"
33
java-devel = "11"
4+
"shared/logback" = "1.2.13"
45

56
[versions."3.9.3".build-arguments]
67
jmx-exporter-version = "1.4.0"
78

89
[versions."3.9.4".local-images]
910
java-base = "17"
1011
java-devel = "11"
12+
"shared/logback" = "1.3.15"
1113

1214
[versions."3.9.4".build-arguments]
1315
jmx-exporter-version = "1.4.0"

0 commit comments

Comments
 (0)