Skip to content

Commit 3211620

Browse files
Add support for Thrift 0.23
1 parent 614c323 commit 3211620

11 files changed

Lines changed: 193 additions & 0 deletions

File tree

dependencies.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ thrift019 = { strictly = "0.19.0" }
184184
thrift020 = { strictly = "0.20.0" }
185185
thrift021 = { strictly = "0.21.0" }
186186
thrift022 = { strictly = "0.22.0" }
187+
thrift023 = { strictly = "0.23.0" }
187188
tomcat8 = "8.5.100"
188189
tomcat9 = "9.0.96"
189190
tomcat10 = "10.1.49"
@@ -1503,6 +1504,14 @@ exclusions = [
15031504
module = "org.apache.thrift:libthrift"
15041505
version.ref = "thrift022"
15051506
javadocs = "https://www.javadoc.io/doc/org.apache.thrift/libthrift/0.22.0/"
1507+
exclusions = [
1508+
"javax.annotation:javax.annotation-api",
1509+
"org.apache.httpcomponents:httpcore",
1510+
"org.apache.httpcomponents:httpclient"]
1511+
[libraries.thrift023]
1512+
module = "org.apache.thrift:libthrift"
1513+
version.ref = "thrift023"
1514+
javadocs = "https://www.javadoc.io/doc/org.apache.thrift/libthrift/0.23.0/"
15061515
exclusions = [
15071516
"javax.annotation:javax.annotation-api",
15081517
"org.apache.httpcomponents:httpcore",
3.44 MB
Binary file not shown.
3.68 MB
Binary file not shown.
3.1 MB
Binary file not shown.
3.31 MB
Binary file not shown.
3.01 MB
Binary file not shown.

settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ includeWithFlags ':thrift0.21', 'java11', 'publish', 'r
202202
project(':thrift0.21').projectDir = file('thrift/thrift0.21')
203203
includeWithFlags ':thrift0.22', 'java11', 'publish', 'relocate', 'no_aggregation', 'native'
204204
project(':thrift0.22').projectDir = file('thrift/thrift0.22')
205+
includeWithFlags ':thrift0.23', 'java11', 'publish', 'relocate', 'no_aggregation', 'native'
206+
project(':thrift0.23').projectDir = file('thrift/thrift0.23')
205207
includeWithFlags ':tomcat8', 'java', 'publish', 'relocate', 'no_aggregation'
206208
includeWithFlags ':tomcat9', 'java', 'publish', 'relocate', 'no_aggregation'
207209
includeWithFlags ':tomcat10', 'java11', 'publish', 'relocate'

thrift/thrift0.23/build.gradle

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// This module builds and publishes 'armeria-thrift0.23', which is compiled with
2+
// the source code of ':thrift0.13', ':thrift0.14.0', ':thrift0.21.0'.
3+
4+
dependencies {
5+
api libs.thrift023
6+
7+
api libs.javax.annotation
8+
9+
testImplementation project(':prometheus1')
10+
11+
// thrift api depends on httpclient5
12+
testImplementation libs.apache.httpclient5
13+
14+
// Jetty, for testing TServlet interoperability.
15+
testImplementation libs.jetty11.webapp
16+
testImplementation libs.jetty11.http2.server
17+
18+
// Dropwizard and Prometheus, for testing metrics integration
19+
testImplementation libs.dropwizard.metrics.core
20+
testImplementation libs.prometheus.metrics.exposition.formats
21+
22+
// micrometer tracing
23+
testImplementation (libs.micrometer.tracing.integration.test) {
24+
exclude group: "org.mockito"
25+
}
26+
testImplementation libs.brave6.instrumentation.http.tests
27+
testImplementation libs.logback14
28+
}
29+
30+
// Use the sources from ':thrift0.13', ':thrift0.14', and ':thrift0.21'.
31+
// Some modules are empty so no need to copy anything.
32+
// NB: We should never add these directories using the 'sourceSets' directive because that will make
33+
// them added to more than one project and having a source directory with more than one output directory
34+
// will confuse IDEs such as IntelliJ IDEA.
35+
def thrift013ProjectDir = "${rootProject.projectDir}/thrift/thrift0.13"
36+
def thrift014ProjectDir = "${rootProject.projectDir}/thrift/thrift0.14"
37+
def thrift017ProjectDir = "${rootProject.projectDir}/thrift/thrift0.17"
38+
def thrift018ProjectDir = "${rootProject.projectDir}/thrift/thrift0.18"
39+
def thrift019ProjectDir = "${rootProject.projectDir}/thrift/thrift0.19"
40+
def thrift021ProjectDir = "${rootProject.projectDir}/thrift/thrift0.21"
41+
42+
// Copy common files from ':thrift0.13', ':thrift0.14', and ':thrift0.21' to gen-src directory
43+
// in order to use them as a source set.
44+
task generateSources(type: Copy) {
45+
from("${thrift013ProjectDir}/src/main/java") {
46+
exclude '**/TByteBufTransport.java'
47+
exclude '**/ThriftCallService.java'
48+
exclude '**/ThriftFunction.java'
49+
exclude '**/ThriftServiceMetadata.java'
50+
exclude '**/MaskingTProtocol.java'
51+
exclude '**/UnMaskingTProtocol.java'
52+
exclude '**/common/thrift/package-info.java'
53+
exclude '**/server/thrift/package-info.java'
54+
exclude '**/common/thrift/logging/package-info.java'
55+
exclude '**/ThriftFieldMaskerSelector.java'
56+
}
57+
from("${thrift014ProjectDir}/src/main/java") {
58+
exclude '**/TByteBufTransport.java'
59+
exclude '**/internal/common/thrift/package-info.java'
60+
}
61+
from "${thrift018ProjectDir}/src/main/java"
62+
from "${thrift019ProjectDir}/src/main/java"
63+
from("${thrift021ProjectDir}/src/main/java") {
64+
exclude '**/internal/common/thrift/package-info.java'
65+
}
66+
into "${project.ext.genSrcDir}/main/java"
67+
}
68+
69+
task generateTestSources(type: Copy) {
70+
from("${thrift013ProjectDir}/src/test/java") {
71+
exclude '**/THttp2Client.java'
72+
exclude '**/ThriftDocServicePluginTest.java'
73+
exclude '**/ApacheClientUtils.java'
74+
exclude '**/ServletTestUtils.java'
75+
}
76+
from "${thrift014ProjectDir}/src/test/java"
77+
from "${thrift017ProjectDir}/src/test/java"
78+
from "${thrift018ProjectDir}/src/test/java"
79+
from "${thrift019ProjectDir}/src/test/java"
80+
into "${project.ext.genSrcDir}/test/java"
81+
}
82+
83+
def thriftFullVersion = libs.thrift023.get().versionConstraint.requiredVersion
84+
ext {
85+
thriftVersion = thriftFullVersion.substring(0, thriftFullVersion.lastIndexOf('.'));
86+
testThriftSrcDirs = ["$thrift013ProjectDir/src/test/thrift", "$projectDir/src/test/thrift",
87+
"$thrift018ProjectDir/src/test/thrift"]
88+
enableAnnotationsAsMetadata()
89+
}
90+
91+
tasks.generateSources.dependsOn(generateTestSources)
92+
tasks.compileJava.dependsOn(generateSources)
93+
tasks.compileTestJava.dependsOn(generateSources)
94+
95+
tasks.processResources.from("${thrift013ProjectDir}/src/main/resources") {
96+
exclude '**/thrift-options.properties'
97+
}
98+
tasks.processTestResources.from "${thrift013ProjectDir}/src/test/resources"
99+
tasks.sourcesJar.from "${thrift013ProjectDir}/src/main/resources"
100+
101+
// Keep the original Guava references in ThriftListenableFuture,
102+
// which is the only place we expose Guava classes in our public API.
103+
// NB: Keep this same with ':thrift0.13'.
104+
tasks.shadedJar.exclude 'com/linecorp/armeria/common/thrift/ThriftListenableFuture*'
105+
tasks.shadedJar.doLast {
106+
ant.jar(update: true, destfile: tasks.shadedJar.archiveFile.get().asFile) {
107+
sourceSets.main.output.classesDirs.each { classesDir ->
108+
fileset(dir: "$classesDir",
109+
includes: 'com/linecorp/armeria/common/thrift/ThriftListenableFuture*')
110+
}
111+
}
112+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2026 LY Corporation
3+
*
4+
* LY Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
package com.linecorp.armeria.internal.common.thrift;
18+
19+
import org.apache.thrift.TConfiguration;
20+
import org.apache.thrift.transport.TTransportException;
21+
22+
import com.linecorp.armeria.common.annotation.Nullable;
23+
24+
import io.netty.buffer.ByteBuf;
25+
26+
public final class TByteBufTransport extends AbstractTByteBufTransport {
27+
28+
public TByteBufTransport(ByteBuf buf) {
29+
super(buf);
30+
}
31+
32+
@Nullable
33+
@Override
34+
public TConfiguration getConfiguration() {
35+
return new TConfiguration();
36+
}
37+
38+
@Override
39+
public void updateKnownMessageSize(long size) throws TTransportException {
40+
// This method is not called by the 'TProtocol's provided by Armeria
41+
}
42+
43+
@Override
44+
public void checkReadBytesAvailable(long numBytes) throws TTransportException {
45+
// The size of readable bytes is already checked by the underlying ByteBuf.
46+
}
47+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2026 LY Corporation
3+
*
4+
* LY Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
/**
18+
* Various classes used internally. Anything in this package can be changed or removed at any time.
19+
*/
20+
@NonNullByDefault
21+
package com.linecorp.armeria.internal.common.thrift;
22+
23+
import com.linecorp.armeria.common.annotation.NonNullByDefault;

0 commit comments

Comments
 (0)