From acae80bd986202031024b4749cb61e260e58664d Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Sat, 30 May 2026 06:41:34 +0100 Subject: [PATCH 1/2] GH-3572: Bump Apache Thrift to 0.23.0 (#3589) * GH-3572 Bump thrift to 0.23 Added instructions in docs as to where to find the gpg/sha signatures and a link to the thrift team KEYS file. * Thrift 0.23 now checks limits (good!) on read write and depth But it means: if you don't supply a TTransport to TProtocol ctor you hit an NPE during IO whenever those limits are validated. Add a StubTTransport which no-ops the read range check and declares there's no limit on depth checking. * Spotless * review feedback (cherry picked from commit fb5d512114c2394b40348fb71dacbc179bf4d577) --- README.md | 14 ++-- dev/ci-before_install.sh | 2 +- .../thrift/BufferedProtocolReadToWrite.java | 2 +- .../parquet/thrift/ParquetProtocol.java | 4 +- .../apache/parquet/thrift/StubTTransport.java | 74 +++++++++++++++++++ pom.xml | 2 +- 6 files changed, 88 insertions(+), 10 deletions(-) create mode 100644 parquet-thrift/src/main/java/org/apache/parquet/thrift/StubTTransport.java diff --git a/README.md b/README.md index ff6f162151..f8c7b326a5 100644 --- a/README.md +++ b/README.md @@ -43,19 +43,23 @@ Parquet-Java uses Maven to build and depends on the thrift compiler (protoc is n To build and install the thrift compiler, run: ``` -wget -nv https://archive.apache.org/dist/thrift/0.22.0/thrift-0.22.0.tar.gz -tar xzf thrift-0.22.0.tar.gz -cd thrift-0.22.0 +wget -nv https://archive.apache.org/dist/thrift/0.23.0/thrift-0.23.0.tar.gz +tar xzf thrift-0.23.0.tar.gz +cd thrift-0.23.0 chmod +x ./configure ./configure --disable-libs sudo make install -j ``` -If you're on OSX and use homebrew, you can instead install Thrift 0.22.0 with `brew` and ensure that it comes first in your `PATH`. +Note: if you wish to verify the signature and checksum of a release: +1. The GPG and sha checksums can be found under https://archive.apache.org/dist/thrift/0.23.0/ +2. Validate the signature of the artifact against the [Thrift committer KEYS](https://downloads.apache.org/thrift/KEYS). + +If you're on OSX and use homebrew, you can instead install Thrift 0.23.0 with `brew` and ensure that it comes first in your `PATH`. ``` brew install thrift -export PATH="/usr/local/opt/thrift@0.22.0/bin:$PATH" +export PATH="/usr/local/opt/thrift@0.23.0/bin:$PATH" ``` ### Build Parquet with Maven diff --git a/dev/ci-before_install.sh b/dev/ci-before_install.sh index 6b57624a23..5b88f18e9a 100755 --- a/dev/ci-before_install.sh +++ b/dev/ci-before_install.sh @@ -20,7 +20,7 @@ # This script gets invoked by the CI system in a "before install" step ################################################################################ -export THRIFT_VERSION=0.22.0 +export THRIFT_VERSION=0.23.0 set -e date diff --git a/parquet-thrift/src/main/java/org/apache/parquet/thrift/BufferedProtocolReadToWrite.java b/parquet-thrift/src/main/java/org/apache/parquet/thrift/BufferedProtocolReadToWrite.java index 7e8a1633f8..e1c2aae57a 100644 --- a/parquet-thrift/src/main/java/org/apache/parquet/thrift/BufferedProtocolReadToWrite.java +++ b/parquet-thrift/src/main/java/org/apache/parquet/thrift/BufferedProtocolReadToWrite.java @@ -579,7 +579,7 @@ private void checkEnum(ThriftType expectedType, int i) { class NullProtocol extends TProtocol { public NullProtocol() { - super(null); + super(StubTTransport.INSTANCE); } @Override diff --git a/parquet-thrift/src/main/java/org/apache/parquet/thrift/ParquetProtocol.java b/parquet-thrift/src/main/java/org/apache/parquet/thrift/ParquetProtocol.java index ab35497181..4094bebc40 100644 --- a/parquet-thrift/src/main/java/org/apache/parquet/thrift/ParquetProtocol.java +++ b/parquet-thrift/src/main/java/org/apache/parquet/thrift/ParquetProtocol.java @@ -38,7 +38,7 @@ public abstract class ParquetProtocol extends TProtocol { private String name; ParquetProtocol() { - super(null); + super(StubTTransport.INSTANCE); } private String getClassInfo() { @@ -54,7 +54,7 @@ private String getClassInfo() { * @param name a meaningful debugging name for anonymous inner classes */ public ParquetProtocol(String name) { - super(null); + super(StubTTransport.INSTANCE); this.name = name; } diff --git a/parquet-thrift/src/main/java/org/apache/parquet/thrift/StubTTransport.java b/parquet-thrift/src/main/java/org/apache/parquet/thrift/StubTTransport.java new file mode 100644 index 0000000000..96718bb51f --- /dev/null +++ b/parquet-thrift/src/main/java/org/apache/parquet/thrift/StubTTransport.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.parquet.thrift; + +import org.apache.thrift.TConfiguration; +import org.apache.thrift.transport.TTransport; +import org.apache.thrift.transport.TTransportException; + +/** + * A stub transport which implements the minimum amount needed for range/depth + * validation within the thrift library to succeed. + */ +final class StubTTransport extends TTransport { + + static final StubTTransport INSTANCE = new StubTTransport(); + + /** + * There's no limits on recursion depth. + */ + private static final TConfiguration CONFIGURATION = new TConfiguration( + TConfiguration.DEFAULT_MAX_FRAME_SIZE, TConfiguration.DEFAULT_MAX_MESSAGE_SIZE, Integer.MAX_VALUE); + + private StubTTransport() {} + + @Override + public void checkReadBytesAvailable(long l) {} + + @Override + public boolean isOpen() { + return true; + } + + @Override + public void open() throws TTransportException { + throw new TTransportException("unsupported"); + } + + @Override + public void close() {} + + @Override + public int read(byte[] bytes, int i, int i1) throws TTransportException { + throw new TTransportException("unsupported"); + } + + @Override + public void write(byte[] bytes, int i, int i1) throws TTransportException { + throw new TTransportException("unsupported"); + } + + @Override + public TConfiguration getConfiguration() { + return CONFIGURATION; + } + + @Override + public void updateKnownMessageSize(long l) {} +} diff --git a/pom.xml b/pom.xml index e986543221..e673dd5cff 100644 --- a/pom.xml +++ b/pom.xml @@ -91,7 +91,7 @@ 0.16.0 h2 0.10.0 - 0.22.0 + 0.23.0 ${thrift.version} 8.5.15 0.9.33 From 37407cf961dee59fb0a0835845f377a6c77d64f9 Mon Sep 17 00:00:00 2001 From: Manu Zhang Date: Wed, 28 Oct 2026 05:35:16 +0800 Subject: [PATCH 2/2] build(deps): [1.18.x] upgrade Thrift to 0.25.0 (#3891) Backport the relevant parts of #3855 directly from 0.23.0 to 0.25.0. Update the runtime and compiler together, align CI and build instructions, and implement the transport reset method required by Thrift 0.25.0. (cherry picked from commit b97860d73c3d38e6d6a61188f5ade88f5a071abc) Co-authored-by: Fokko Driesprong Co-authored-by: Codex (cherry picked from commit 01bb09c226c0428612e9b4df74ac73b39b8c2344) --- README.md | 12 ++++++------ dev/ci-before_install.sh | 2 +- .../org/apache/parquet/thrift/StubTTransport.java | 3 +++ pom.xml | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f8c7b326a5..d229a5474d 100644 --- a/README.md +++ b/README.md @@ -43,23 +43,23 @@ Parquet-Java uses Maven to build and depends on the thrift compiler (protoc is n To build and install the thrift compiler, run: ``` -wget -nv https://archive.apache.org/dist/thrift/0.23.0/thrift-0.23.0.tar.gz -tar xzf thrift-0.23.0.tar.gz -cd thrift-0.23.0 +wget -nv https://archive.apache.org/dist/thrift/0.25.0/thrift-0.25.0.tar.gz +tar xzf thrift-0.25.0.tar.gz +cd thrift-0.25.0 chmod +x ./configure ./configure --disable-libs sudo make install -j ``` Note: if you wish to verify the signature and checksum of a release: -1. The GPG and sha checksums can be found under https://archive.apache.org/dist/thrift/0.23.0/ +1. The GPG and sha checksums can be found under https://archive.apache.org/dist/thrift/0.25.0/ 2. Validate the signature of the artifact against the [Thrift committer KEYS](https://downloads.apache.org/thrift/KEYS). -If you're on OSX and use homebrew, you can instead install Thrift 0.23.0 with `brew` and ensure that it comes first in your `PATH`. +If you're on OSX and use homebrew, you can instead install Thrift 0.25.0 with `brew` and ensure that it comes first in your `PATH`. ``` brew install thrift -export PATH="/usr/local/opt/thrift@0.23.0/bin:$PATH" +export PATH="/usr/local/opt/thrift@0.25.0/bin:$PATH" ``` ### Build Parquet with Maven diff --git a/dev/ci-before_install.sh b/dev/ci-before_install.sh index 5b88f18e9a..7d68e34f81 100755 --- a/dev/ci-before_install.sh +++ b/dev/ci-before_install.sh @@ -20,7 +20,7 @@ # This script gets invoked by the CI system in a "before install" step ################################################################################ -export THRIFT_VERSION=0.23.0 +export THRIFT_VERSION=0.25.0 set -e date diff --git a/parquet-thrift/src/main/java/org/apache/parquet/thrift/StubTTransport.java b/parquet-thrift/src/main/java/org/apache/parquet/thrift/StubTTransport.java index 96718bb51f..4bdf189e42 100644 --- a/parquet-thrift/src/main/java/org/apache/parquet/thrift/StubTTransport.java +++ b/parquet-thrift/src/main/java/org/apache/parquet/thrift/StubTTransport.java @@ -71,4 +71,7 @@ public TConfiguration getConfiguration() { @Override public void updateKnownMessageSize(long l) {} + + @Override + public void resetMessageSizeAndConsumedBytes(long l) {} } diff --git a/pom.xml b/pom.xml index e673dd5cff..362fe1bfd7 100644 --- a/pom.xml +++ b/pom.xml @@ -91,7 +91,7 @@ 0.16.0 h2 0.10.0 - 0.23.0 + 0.25.0 ${thrift.version} 8.5.15 0.9.33