Skip to content

Commit cce8164

Browse files
apurtellclaude
andauthored
HBASE-30195 Update Thrift gateway to use new hbase-shaded-thrift in thirdparty (apache#8299)
Signed-off-by: Dávid Paksy <paksyd@apache.org> Signed-off-by: Duo Zhang <zhangduo@apache.org> Signed-off-by: Pankaj Kumar <pankajkumar@apache.org> Signed-off-by: Xiao Liu <liuxiaocs@apache.org> Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
1 parent e992c03 commit cce8164

87 files changed

Lines changed: 37969 additions & 30460 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

hbase-examples/pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,14 @@
110110
<artifactId>hbase-testing-util</artifactId>
111111
<scope>test</scope>
112112
</dependency>
113+
<!--
114+
Thrift runtime classes come from the relocated/shaded artifact in hbase-thirdparty
115+
(org.apache.hbase.thirdparty.org.apache.thrift.*) instead of upstream libthrift. See
116+
HBASE-30194 and hbase-thirdparty/hbase-shaded-thrift.
117+
-->
113118
<dependency>
114-
<groupId>org.apache.thrift</groupId>
115-
<artifactId>libthrift</artifactId>
119+
<groupId>org.apache.hbase.thirdparty</groupId>
120+
<artifactId>hbase-shaded-thrift</artifactId>
116121
</dependency>
117122
<dependency>
118123
<groupId>commons-io</groupId>

hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@
3535
import org.apache.hadoop.hbase.thrift.generated.TRowResult;
3636
import org.apache.hadoop.hbase.util.Bytes;
3737
import org.apache.hadoop.hbase.util.ClientUtils;
38-
import org.apache.thrift.protocol.TBinaryProtocol;
39-
import org.apache.thrift.protocol.TProtocol;
40-
import org.apache.thrift.transport.TSaslClientTransport;
41-
import org.apache.thrift.transport.TSocket;
42-
import org.apache.thrift.transport.TTransport;
4338
import org.apache.yetus.audience.InterfaceAudience;
4439

40+
import org.apache.hbase.thirdparty.org.apache.thrift.protocol.TBinaryProtocol;
41+
import org.apache.hbase.thirdparty.org.apache.thrift.protocol.TProtocol;
42+
import org.apache.hbase.thirdparty.org.apache.thrift.transport.TSaslClientTransport;
43+
import org.apache.hbase.thirdparty.org.apache.thrift.transport.TSocket;
44+
import org.apache.hbase.thirdparty.org.apache.thrift.transport.TTransport;
45+
4546
/**
4647
* See the instructions under hbase-examples/README.txt
4748
*/

hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/HttpDoAsClient.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@
3737
import org.apache.hadoop.hbase.thrift.generated.Hbase;
3838
import org.apache.hadoop.hbase.util.Bytes;
3939
import org.apache.hadoop.hbase.util.ClientUtils;
40-
import org.apache.thrift.protocol.TBinaryProtocol;
41-
import org.apache.thrift.protocol.TProtocol;
42-
import org.apache.thrift.transport.THttpClient;
43-
import org.apache.thrift.transport.TSocket;
44-
import org.apache.thrift.transport.TTransport;
4540
import org.apache.yetus.audience.InterfaceAudience;
4641
import org.ietf.jgss.GSSContext;
4742
import org.ietf.jgss.GSSCredential;
@@ -52,6 +47,12 @@
5247
import org.slf4j.Logger;
5348
import org.slf4j.LoggerFactory;
5449

50+
import org.apache.hbase.thirdparty.org.apache.thrift.protocol.TBinaryProtocol;
51+
import org.apache.hbase.thirdparty.org.apache.thrift.protocol.TProtocol;
52+
import org.apache.hbase.thirdparty.org.apache.thrift.transport.THttpClient;
53+
import org.apache.hbase.thirdparty.org.apache.thrift.transport.TSocket;
54+
import org.apache.hbase.thirdparty.org.apache.thrift.transport.TTransport;
55+
5556
/**
5657
* See the instructions under hbase-examples/README.txt
5758
*/

hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift2/DemoClient.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,16 @@
3535
import org.apache.hadoop.hbase.thrift2.generated.TResult;
3636
import org.apache.hadoop.hbase.util.Bytes;
3737
import org.apache.hadoop.hbase.util.ClientUtils;
38-
import org.apache.thrift.TConfiguration;
39-
import org.apache.thrift.protocol.TBinaryProtocol;
40-
import org.apache.thrift.protocol.TProtocol;
41-
import org.apache.thrift.transport.TSaslClientTransport;
42-
import org.apache.thrift.transport.TSocket;
43-
import org.apache.thrift.transport.TTransport;
44-
import org.apache.thrift.transport.layered.TFramedTransport;
4538
import org.apache.yetus.audience.InterfaceAudience;
4639

40+
import org.apache.hbase.thirdparty.org.apache.thrift.TConfiguration;
41+
import org.apache.hbase.thirdparty.org.apache.thrift.protocol.TBinaryProtocol;
42+
import org.apache.hbase.thirdparty.org.apache.thrift.protocol.TProtocol;
43+
import org.apache.hbase.thirdparty.org.apache.thrift.transport.TSaslClientTransport;
44+
import org.apache.hbase.thirdparty.org.apache.thrift.transport.TSocket;
45+
import org.apache.hbase.thirdparty.org.apache.thrift.transport.TTransport;
46+
import org.apache.hbase.thirdparty.org.apache.thrift.transport.layered.TFramedTransport;
47+
4748
@InterfaceAudience.Private
4849
public class DemoClient {
4950
private static String host = "localhost";

hbase-thrift/pom.xml

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,15 @@
8484
<groupId>org.apache.hbase</groupId>
8585
<artifactId>hbase-hadoop-compat</artifactId>
8686
</dependency>
87+
<!--
88+
Thrift runtime classes come from the relocated/shaded artifact in hbase-thirdparty
89+
(org.apache.hbase.thirdparty.org.apache.thrift.*) instead of upstream libthrift. This
90+
avoids the libthrift CVE chain and lets us keep Java 8 / javax.servlet / Apache
91+
HttpClient 4.x compatibility regardless of upstream's choices. See HBASE-30194.
92+
-->
8793
<dependency>
88-
<groupId>org.apache.thrift</groupId>
89-
<artifactId>libthrift</artifactId>
94+
<groupId>org.apache.hbase.thirdparty</groupId>
95+
<artifactId>hbase-shaded-thrift</artifactId>
9096
</dependency>
9197
<dependency>
9298
<groupId>org.junit.jupiter</groupId>
@@ -371,12 +377,15 @@
371377
<requireProperty>
372378
<property>thrift.version</property>
373379
<message>"The Thrift version must be specified."</message>
374-
<regex>0\.14\.1</regex>
380+
<regex>0\.23\.\d+</regex>
375381
<regexMessage>-
376382
-
377383
[FATAL] ==========================================================================================
378-
[FATAL] HBase Thrift requires the thrift generator version 0.14.1.
379-
[FATAL] Setting it to something else needs to be reviewed for wire and behavior compatibility.
384+
[FATAL] HBase Thrift requires the thrift generator version 0.23.x (matching the libthrift
385+
[FATAL] runtime shipped in hbase-thirdparty/hbase-shaded-thrift). Setting it to something else
386+
[FATAL] needs to be reviewed for wire and behavior compatibility, and for source compatibility
387+
[FATAL] with the maven-replacer-plugin rewrite that retargets generated code to the shaded
388+
[FATAL] org.apache.hbase.thirdparty.org.apache.thrift namespace.
380389
[FATAL] ==========================================================================================
381390
-
382391
-</regexMessage>
@@ -450,6 +459,42 @@
450459
</execution>
451460
</executions>
452461
</plugin>
462+
<!--
463+
After the Thrift IDL compiler regenerates Java sources under src/main/java/.../generated,
464+
rewrite the `import org.apache.thrift.*` lines (and qualified references) to point at
465+
the relocated namespace used by org.apache.hbase.thirdparty:hbase-shaded-thrift. The
466+
committed generated sources are expected to already contain the rewritten imports;
467+
this step keeps the in-tree files in sync after a regeneration. The regex is
468+
idempotent: it leaves any already-shaded `org.apache.hbase.thirdparty.org.apache.thrift`
469+
references alone (we only match when not preceded by a dot).
470+
-->
471+
<plugin>
472+
<groupId>com.google.code.maven-replacer-plugin</groupId>
473+
<artifactId>replacer</artifactId>
474+
<configuration>
475+
<basedir>${basedir}/src/main/java</basedir>
476+
<includes>
477+
<include>org/apache/hadoop/hbase/thrift/generated/**/*.java</include>
478+
<include>org/apache/hadoop/hbase/thrift2/generated/**/*.java</include>
479+
</includes>
480+
<ignoreErrors>false</ignoreErrors>
481+
<replacements>
482+
<replacement>
483+
<token>([^.])org\.apache\.thrift</token>
484+
<value>$1org.apache.hbase.thirdparty.org.apache.thrift</value>
485+
</replacement>
486+
</replacements>
487+
</configuration>
488+
<executions>
489+
<execution>
490+
<id>shade-generated-thrift-imports</id>
491+
<goals>
492+
<goal>replace</goal>
493+
</goals>
494+
<phase>process-sources</phase>
495+
</execution>
496+
</executions>
497+
</plugin>
453498
</plugins>
454499
</build>
455500
</profile>

hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/HThreadedSelectorServerArgs.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919

2020
import java.util.Locale;
2121
import org.apache.hadoop.conf.Configuration;
22-
import org.apache.thrift.server.TThreadedSelectorServer;
23-
import org.apache.thrift.transport.TNonblockingServerTransport;
2422
import org.apache.yetus.audience.InterfaceAudience;
2523
import org.slf4j.Logger;
2624
import org.slf4j.LoggerFactory;
2725

26+
import org.apache.hbase.thirdparty.org.apache.thrift.server.TThreadedSelectorServer;
27+
import org.apache.hbase.thirdparty.org.apache.thrift.transport.TNonblockingServerTransport;
28+
2829
/**
2930
* A TThreadedSelectorServer.Args that reads hadoop configuration
3031
*/

hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ImplType.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@
2323
import java.util.Arrays;
2424
import java.util.List;
2525
import org.apache.hadoop.conf.Configuration;
26-
import org.apache.thrift.server.THsHaServer;
27-
import org.apache.thrift.server.TNonblockingServer;
28-
import org.apache.thrift.server.TServer;
29-
import org.apache.thrift.server.TThreadedSelectorServer;
3026
import org.apache.yetus.audience.InterfaceAudience;
3127
import org.slf4j.Logger;
3228
import org.slf4j.LoggerFactory;
3329

3430
import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine;
3531
import org.apache.hbase.thirdparty.org.apache.commons.cli.Option;
3632
import org.apache.hbase.thirdparty.org.apache.commons.cli.OptionGroup;
33+
import org.apache.hbase.thirdparty.org.apache.thrift.server.THsHaServer;
34+
import org.apache.hbase.thirdparty.org.apache.thrift.server.TNonblockingServer;
35+
import org.apache.hbase.thirdparty.org.apache.thrift.server.TServer;
36+
import org.apache.hbase.thirdparty.org.apache.thrift.server.TThreadedSelectorServer;
3737

3838
/** An enum of server implementation selections */
3939
@InterfaceAudience.Private

hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/TBoundedThreadPoolServer.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@
2626
import org.apache.hadoop.conf.Configuration;
2727
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
2828
import org.apache.hadoop.hbase.util.Threads;
29-
import org.apache.thrift.TException;
30-
import org.apache.thrift.TProcessor;
31-
import org.apache.thrift.protocol.TProtocol;
32-
import org.apache.thrift.server.TServer;
33-
import org.apache.thrift.server.TThreadPoolServer;
34-
import org.apache.thrift.transport.TServerTransport;
35-
import org.apache.thrift.transport.TSocket;
36-
import org.apache.thrift.transport.TTransport;
37-
import org.apache.thrift.transport.TTransportException;
3829
import org.apache.yetus.audience.InterfaceAudience;
3930
import org.slf4j.Logger;
4031
import org.slf4j.LoggerFactory;
4132

4233
import org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder;
34+
import org.apache.hbase.thirdparty.org.apache.thrift.TException;
35+
import org.apache.hbase.thirdparty.org.apache.thrift.TProcessor;
36+
import org.apache.hbase.thirdparty.org.apache.thrift.protocol.TProtocol;
37+
import org.apache.hbase.thirdparty.org.apache.thrift.server.TServer;
38+
import org.apache.hbase.thirdparty.org.apache.thrift.server.TThreadPoolServer;
39+
import org.apache.hbase.thirdparty.org.apache.thrift.transport.TServerTransport;
40+
import org.apache.hbase.thirdparty.org.apache.thrift.transport.TSocket;
41+
import org.apache.hbase.thirdparty.org.apache.thrift.transport.TTransport;
42+
import org.apache.hbase.thirdparty.org.apache.thrift.transport.TTransportException;
4343

4444
/**
4545
* A bounded thread pool server customized for HBase.

hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftHBaseServiceHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@
8282
import org.apache.hadoop.hbase.thrift.generated.TScan;
8383
import org.apache.hadoop.hbase.thrift.generated.TThriftServerType;
8484
import org.apache.hadoop.hbase.util.Bytes;
85-
import org.apache.thrift.TException;
8685
import org.apache.yetus.audience.InterfaceAudience;
8786
import org.slf4j.Logger;
8887
import org.slf4j.LoggerFactory;
8988

9089
import org.apache.hbase.thirdparty.com.google.common.base.Throwables;
90+
import org.apache.hbase.thirdparty.org.apache.thrift.TException;
9191

9292
/**
9393
* The HBaseServiceHandler is a glue object that connects Thrift RPC calls to the HBase client API

hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftHttpServlet.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
import org.apache.hadoop.security.authorize.AuthorizationException;
3131
import org.apache.hadoop.security.authorize.ProxyUsers;
3232
import org.apache.http.HttpHeaders;
33-
import org.apache.thrift.TProcessor;
34-
import org.apache.thrift.protocol.TProtocolFactory;
35-
import org.apache.thrift.server.TServlet;
3633
import org.apache.yetus.audience.InterfaceAudience;
3734
import org.ietf.jgss.GSSContext;
3835
import org.ietf.jgss.GSSCredential;
@@ -43,6 +40,10 @@
4340
import org.slf4j.Logger;
4441
import org.slf4j.LoggerFactory;
4542

43+
import org.apache.hbase.thirdparty.org.apache.thrift.TProcessor;
44+
import org.apache.hbase.thirdparty.org.apache.thrift.protocol.TProtocolFactory;
45+
import org.apache.hbase.thirdparty.org.apache.thrift.server.TServlet;
46+
4647
/**
4748
* Thrift Http Servlet is used for performing Kerberos authentication if security is enabled and
4849
* also used for setting the user specified in "doAs" parameter.

0 commit comments

Comments
 (0)