Skip to content

Commit fb5d512

Browse files
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
1 parent dc3f1ac commit fb5d512

6 files changed

Lines changed: 88 additions & 10 deletions

File tree

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,23 @@ Parquet-Java uses Maven to build and depends on the thrift compiler (protoc is n
4343
To build and install the thrift compiler, run:
4444

4545
```
46-
wget -nv https://archive.apache.org/dist/thrift/0.22.0/thrift-0.22.0.tar.gz
47-
tar xzf thrift-0.22.0.tar.gz
48-
cd thrift-0.22.0
46+
wget -nv https://archive.apache.org/dist/thrift/0.23.0/thrift-0.23.0.tar.gz
47+
tar xzf thrift-0.23.0.tar.gz
48+
cd thrift-0.23.0
4949
chmod +x ./configure
5050
./configure --disable-libs
5151
sudo make install -j
5252
```
5353

54-
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`.
54+
Note: if you wish to verify the signature and checksum of a release:
55+
1. The GPG and sha checksums can be found under https://archive.apache.org/dist/thrift/0.23.0/
56+
2. Validate the signature of the artifact against the [Thrift committer KEYS](https://downloads.apache.org/thrift/KEYS).
57+
58+
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`.
5559

5660
```
5761
brew install thrift
58-
export PATH="/usr/local/opt/thrift@0.22.0/bin:$PATH"
62+
export PATH="/usr/local/opt/thrift@0.23.0/bin:$PATH"
5963
```
6064

6165
### Build Parquet with Maven

dev/ci-before_install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# This script gets invoked by the CI system in a "before install" step
2121
################################################################################
2222

23-
export THRIFT_VERSION=0.22.0
23+
export THRIFT_VERSION=0.23.0
2424

2525
set -e
2626
set -o pipefail

parquet-thrift/src/main/java/org/apache/parquet/thrift/BufferedProtocolReadToWrite.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ private void checkEnum(ThriftType expectedType, int i) {
579579
class NullProtocol extends TProtocol {
580580

581581
public NullProtocol() {
582-
super(null);
582+
super(StubTTransport.INSTANCE);
583583
}
584584

585585
@Override

parquet-thrift/src/main/java/org/apache/parquet/thrift/ParquetProtocol.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public abstract class ParquetProtocol extends TProtocol {
3838
private String name;
3939

4040
ParquetProtocol() {
41-
super(null);
41+
super(StubTTransport.INSTANCE);
4242
}
4343

4444
private String getClassInfo() {
@@ -54,7 +54,7 @@ private String getClassInfo() {
5454
* @param name a meaningful debugging name for anonymous inner classes
5555
*/
5656
public ParquetProtocol(String name) {
57-
super(null);
57+
super(StubTTransport.INSTANCE);
5858
this.name = name;
5959
}
6060

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with 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+
19+
package org.apache.parquet.thrift;
20+
21+
import org.apache.thrift.TConfiguration;
22+
import org.apache.thrift.transport.TTransport;
23+
import org.apache.thrift.transport.TTransportException;
24+
25+
/**
26+
* A stub transport which implements the minimum amount needed for range/depth
27+
* validation within the thrift library to succeed.
28+
*/
29+
final class StubTTransport extends TTransport {
30+
31+
static final StubTTransport INSTANCE = new StubTTransport();
32+
33+
/**
34+
* There's no limits on recursion depth.
35+
*/
36+
private static final TConfiguration CONFIGURATION = new TConfiguration(
37+
TConfiguration.DEFAULT_MAX_FRAME_SIZE, TConfiguration.DEFAULT_MAX_MESSAGE_SIZE, Integer.MAX_VALUE);
38+
39+
private StubTTransport() {}
40+
41+
@Override
42+
public void checkReadBytesAvailable(long l) {}
43+
44+
@Override
45+
public boolean isOpen() {
46+
return true;
47+
}
48+
49+
@Override
50+
public void open() throws TTransportException {
51+
throw new TTransportException("unsupported");
52+
}
53+
54+
@Override
55+
public void close() {}
56+
57+
@Override
58+
public int read(byte[] bytes, int i, int i1) throws TTransportException {
59+
throw new TTransportException("unsupported");
60+
}
61+
62+
@Override
63+
public void write(byte[] bytes, int i, int i1) throws TTransportException {
64+
throw new TTransportException("unsupported");
65+
}
66+
67+
@Override
68+
public TConfiguration getConfiguration() {
69+
return CONFIGURATION;
70+
}
71+
72+
@Override
73+
public void updateKnownMessageSize(long l) {}
74+
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
<thrift.executable>thrift</thrift.executable>
9090
<format.thrift.executable>${thrift.executable}</format.thrift.executable>
9191
<thrift-maven-plugin.version>0.10.0</thrift-maven-plugin.version>
92-
<thrift.version>0.22.0</thrift.version>
92+
<thrift.version>0.23.0</thrift.version>
9393
<format.thrift.version>${thrift.version}</format.thrift.version>
9494
<fastutil.version>8.5.18</fastutil.version>
9595
<semver.api.version>0.9.33</semver.api.version>

0 commit comments

Comments
 (0)