Skip to content

Commit 4c2ddc5

Browse files
author
smohite
committed
HIVE-29393: Upgrade Jetty 9.4.x to 10.0.24
1 parent 4e48dce commit 4c2ddc5

File tree

17 files changed

+91
-81
lines changed

17 files changed

+91
-81
lines changed

common/src/java/org/apache/hive/http/HttpServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ ServerConnector createAndAddChannelConnector(int queueSize, Builder b) {
661661
if (!b.useSSL) {
662662
connector = new ServerConnector(webServer, http);
663663
} else {
664-
SslContextFactory sslContextFactory = new SslContextFactory.Server();
664+
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
665665
sslContextFactory.setKeyStorePath(b.keyStorePath);
666666
sslContextFactory.setKeyStoreType(b.keyStoreType == null || b.keyStoreType.isEmpty() ?
667667
KeyStore.getDefaultType(): b.keyStoreType);

common/src/java/org/apache/hive/http/security/PamAuthenticator.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
import org.eclipse.jetty.security.authentication.LoginAuthenticator;
2525
import org.eclipse.jetty.server.Authentication;
2626
import org.eclipse.jetty.server.UserIdentity;
27-
import org.eclipse.jetty.util.B64Code;
27+
import java.util.Base64;
28+
import java.nio.charset.StandardCharsets;
2829

2930
import javax.security.sasl.AuthenticationException;
3031
import javax.servlet.ServletRequest;
@@ -41,9 +42,9 @@
4142
This class authenticates HS2 web UI via PAM. To authenticate use
4243
4344
* httpGet with header name "Authorization"
44-
* and header value "Basic authB64Code"
45+
* and header value "Basic authBase64Code"
4546
46-
where authB64Code is Base64 string for "login:password"
47+
where authBase64Code is Base64 string for "login:password"
4748
*/
4849

4950
public class PamAuthenticator extends LoginAuthenticator {
@@ -79,7 +80,8 @@ public Authentication validateRequest(ServletRequest req, ServletResponse res, b
7980
String method = credentials.substring(0, space);
8081
if ("basic".equalsIgnoreCase(method)) {
8182
credentials = credentials.substring(space + 1);
82-
credentials = B64Code.decode(credentials, StandardCharsets.ISO_8859_1);
83+
byte[] decodedBytes = Base64.getDecoder().decode(credentials);
84+
credentials = new String(decodedBytes, StandardCharsets.ISO_8859_1);
8385
int i = credentials.indexOf(':');
8486
if (i > 0) {
8587
String username = credentials.substring(0, i);

hcatalog/webhcat/svr/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@
234234
<artifactId>junit-vintage-engine</artifactId>
235235
<scope>test</scope>
236236
</dependency>
237+
<dependency>
238+
<groupId>org.eclipse.jetty</groupId>
239+
<artifactId>jetty-util</artifactId>
240+
</dependency>
237241
</dependencies>
238242
<build>
239243
<resources>

hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Main.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import java.io.File;
2727
import java.io.FileInputStream;
2828
import java.io.IOException;
29+
import java.nio.file.Path;
30+
import java.nio.file.Paths;
2931
import java.util.ArrayList;
3032
import java.util.EnumSet;
3133
import java.util.HashMap;
@@ -35,6 +37,7 @@
3537
import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
3638
import org.apache.hadoop.security.authentication.server.KerberosAuthenticationHandler;
3739
import org.apache.hadoop.hive.common.IPStackUtils;
40+
import org.eclipse.jetty.util.resource.PathResource;
3841
import org.slf4j.Logger;
3942
import org.slf4j.LoggerFactory;
4043
import org.apache.commons.lang3.StringUtils;
@@ -63,6 +66,7 @@
6366
import org.eclipse.jetty.servlet.ServletContextHandler;
6467
import org.eclipse.jetty.servlet.ServletHolder;
6568
import org.eclipse.jetty.util.ssl.SslContextFactory;
69+
import org.eclipse.jetty.util.resource.Resource;
6670
import org.eclipse.jetty.xml.XmlConfiguration;
6771
import org.slf4j.bridge.SLF4JBridgeHandler;
6872

@@ -204,9 +208,11 @@ public Server runServer(int port)
204208
if (StringUtils.isEmpty(conf.jettyConfiguration())) {
205209
server = new Server(port);
206210
} else {
207-
FileInputStream jettyConf = new FileInputStream(conf.jettyConfiguration());
208-
XmlConfiguration configuration = new XmlConfiguration(jettyConf);
209-
server = (Server)configuration.configure();
211+
Path configPath = Paths.get(conf.jettyConfiguration());
212+
PathResource jettyResource = new PathResource(configPath);
213+
214+
XmlConfiguration configuration = new XmlConfiguration(jettyResource);
215+
server = (Server) configuration.configure();
210216
}
211217

212218
ServletContextHandler root = new ServletContextHandler(server, "/");
@@ -289,7 +295,7 @@ private Connector createChannelConnector(Server server) {
289295

290296
if (conf.getBoolean(AppConfig.USE_SSL, false)) {
291297
LOG.info("Using SSL for templeton.");
292-
SslContextFactory sslContextFactory = new SslContextFactory.Server();
298+
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
293299
sslContextFactory.setKeyStorePath(conf.get(AppConfig.KEY_STORE_PATH, DEFAULT_KEY_STORE_PATH));
294300
sslContextFactory.setKeyStorePassword(conf.get(AppConfig.KEY_STORE_PASSWORD, DEFAULT_KEY_STORE_PASSWORD));
295301
Set<String> excludedSSLProtocols = Sets.newHashSet(Splitter.on(",").trimResults().omitEmptyStrings()

itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestActivePassiveHA.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
import org.apache.http.StatusLine;
6060
import org.apache.http.util.EntityUtils;
6161
import org.eclipse.jetty.http.HttpHeader;
62-
import org.eclipse.jetty.util.B64Code;
62+
import java.util.Base64;
6363
import org.eclipse.jetty.util.StringUtil;
6464
import org.junit.After;
6565
import org.junit.AfterClass;
@@ -812,9 +812,9 @@ private String sendAuthMethod(HttpRequestBase method, boolean enableAuth, boolea
812812
}
813813

814814
private void setupAuthHeaders(final HttpRequestBase method) {
815-
String authB64Code =
816-
B64Code.encode(ADMIN_USER + ":" + ADMIN_PASSWORD, StringUtil.__ISO_8859_1);
817-
method.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authB64Code);
815+
String credentials = ADMIN_USER + ":" + ADMIN_PASSWORD;
816+
String authBase64Code = Base64.getEncoder().encodeToString(credentials.getBytes(StandardCharsets.ISO_8859_1));
817+
method.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authBase64Code);
818818
}
819819

820820
private Map<String, String> getConfOverlay(final String instanceId) {

itests/qtest-druid/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<hive.path.to.root>../..</hive.path.to.root>
3333
<druid.curator.version>4.0.0</druid.curator.version>
3434
<druid.jersey.version>1.19.3</druid.jersey.version>
35-
<druid.jetty.version>9.4.57.v20241219</druid.jetty.version>
35+
<druid.jetty.version>10.0.24</druid.jetty.version>
3636
<druid.derby.version>10.11.1.1</druid.derby.version>
3737
<druid.guava.version>16.0.1</druid.guava.version>
3838
<druid.guice.version>4.1.0</druid.guice.version>

packaging/src/license/licenses.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@
301301
</dependency>
302302
<dependency>
303303
<groupId>org.eclipse.jetty.websocket</groupId>
304-
<artifactId>websocket-api</artifactId>
305-
<version>9.4.57.v20241219</version>
304+
<artifactId>websocket-jetty-api</artifactId>
305+
<version>10.0.24</version>
306306
<licenses>
307307
<license>
308308
<name>Apache Software License - Version 2.0</name>
@@ -313,8 +313,8 @@
313313
</dependency>
314314
<dependency>
315315
<groupId>org.eclipse.jetty.websocket</groupId>
316-
<artifactId>websocket-client</artifactId>
317-
<version>9.4.57.v20241219</version>
316+
<artifactId>websocket-jetty-client</artifactId>
317+
<version>10.0.24</version>
318318
<licenses>
319319
<license>
320320
<name>Apache Software License - Version 2.0</name>
@@ -337,8 +337,8 @@
337337
</dependency>
338338
<dependency>
339339
<groupId>org.eclipse.jetty.websocket</groupId>
340-
<artifactId>websocket-server</artifactId>
341-
<version>9.4.57.v20241219</version>
340+
<artifactId>websocket-jetty-server</artifactId>
341+
<version>10.0.24</version>
342342
<licenses>
343343
<license>
344344
<name>Apache Software License - Version 2.0</name>
@@ -507,7 +507,7 @@
507507
<dependency>
508508
<groupId>org.eclipse.jetty</groupId>
509509
<artifactId>jetty-server</artifactId>
510-
<version>9.4.57.v20241219</version>
510+
<version>10.0.24</version>
511511
<licenses>
512512
<license>
513513
<name>Apache Software License - Version 2.0</name>
@@ -531,7 +531,7 @@
531531
<dependency>
532532
<groupId>org.eclipse.jetty</groupId>
533533
<artifactId>jetty-util-ajax</artifactId>
534-
<version>9.4.57.v20241219</version>
534+
<version>10.0.24</version>
535535
<licenses>
536536
<license>
537537
<name>Apache Software License - Version 2.0</name>
@@ -543,7 +543,7 @@
543543
<dependency>
544544
<groupId>org.eclipse.jetty</groupId>
545545
<artifactId>jetty-util</artifactId>
546-
<version>9.4.57.v20241219</version>
546+
<version>10.0.24</version>
547547
<licenses>
548548
<license>
549549
<name>Apache Software License - Version 2.0</name>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
<javax-servlet.version>3.1.0</javax-servlet.version>
161161
<javolution.version>5.5.1</javolution.version>
162162
<jettison.version>1.5.4</jettison.version>
163-
<jetty.version>9.4.57.v20241219</jetty.version>
163+
<jetty.version>10.0.24</jetty.version>
164164
<jersey.version>1.19.4</jersey.version>
165165
<!-- HIVE-28992: only upgrade to newer than 3.25.0 if you tested the prompt -->
166166
<jline.version>3.25.0</jline.version>

service/src/java/org/apache/hive/service/cli/thrift/ThriftHttpCLIService.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,22 +126,18 @@ public void setThreadFactory(ThreadFactory threadFactory) {
126126
conf.setResponseHeaderSize(responseHeaderSize);
127127
conf.setSendServerVersion(false);
128128
conf.setSendXPoweredBy(false);
129-
final HttpConnectionFactory http = new HttpConnectionFactory(conf) {
130-
public Connection newConnection(Connector connector, EndPoint endPoint) {
131-
Connection connection = super.newConnection(connector, endPoint);
132-
connection.addListener(new Connection.Listener() {
133-
public void onOpened(Connection connection) {
134-
openConnection();
135-
}
136-
137-
public void onClosed(Connection connection) {
138-
closeConnection();
139-
}
140-
});
141-
return connection;
129+
final HttpConnectionFactory http = new HttpConnectionFactory(conf);
130+
http.addBean(new Connection.Listener() {
131+
@Override
132+
public void onOpened(Connection connection) {
133+
openConnection();
142134
}
143-
};
144135

136+
@Override
137+
public void onClosed(Connection connection) {
138+
closeConnection();
139+
}
140+
});
145141
boolean useSsl = hiveConf.getBoolVar(ConfVars.HIVE_SERVER2_USE_SSL);
146142
String schemeName = useSsl ? "https" : "http";
147143

@@ -163,7 +159,7 @@ public void onClosed(Connection connection) {
163159
if (keyStoreAlgorithm.isEmpty()) {
164160
keyStoreAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
165161
}
166-
SslContextFactory sslContextFactory = new SslContextFactory.Server();
162+
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
167163
String[] excludedProtocols = hiveConf.getVar(ConfVars.HIVE_SSL_PROTOCOL_BLACKLIST).split(",");
168164
LOG.info("HTTP Server SSL: adding excluded protocols: " + Arrays.toString(excludedProtocols));
169165
sslContextFactory.addExcludeProtocols(excludedProtocols);

service/src/test/org/apache/hive/service/server/TestHS2HttpServerLDAP.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
import org.apache.http.params.BasicHttpParams;
3636
import org.apache.http.params.HttpParams;
3737
import org.eclipse.jetty.http.HttpHeader;
38-
import org.eclipse.jetty.util.B64Code;
38+
import java.util.Base64;
39+
import java.nio.charset.StandardCharsets;
3940
import org.eclipse.jetty.util.StringUtil;
4041

4142
import java.nio.charset.StandardCharsets;
@@ -89,8 +90,9 @@ public void testValidCredentialsWithAuthorizationHeader() throws Exception {
8990
httpclient = builder.build();
9091

9192
HttpGet httpGet = new HttpGet("http://" + HOST + ":" + webUIPort + "/jmx");
92-
String authB64Code = B64Code.encode(VALID_USER + ":" + VALID_PASS, StringUtil.__ISO_8859_1);
93-
httpGet.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authB64Code);
93+
String credentials = VALID_USER + ":" + VALID_PASS;
94+
String authBase64Code = Base64.getEncoder().encodeToString(credentials.getBytes(StandardCharsets.ISO_8859_1));
95+
httpGet.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authBase64Code);
9496
httpclient.execute(httpGet);
9597

9698
Assert.assertTrue(isAuthorized(httpCookieStore.getCookies()));
@@ -110,8 +112,9 @@ public void testInvalidCredentialsWithInAuthorizationHeader() throws Exception {
110112
httpclient = builder.build();
111113

112114
HttpGet httpGet = new HttpGet("http://" + HOST + ":" + webUIPort + "/jmx");
113-
String authB64Code = B64Code.encode(INVALID_USER + ":" + INVALID_PASS, StringUtil.__ISO_8859_1);
114-
httpGet.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authB64Code);
115+
String credentials = INVALID_USER + ":" + INVALID_PASS;
116+
String authBase64Code = Base64.getEncoder().encodeToString(credentials.getBytes(StandardCharsets.ISO_8859_1));
117+
httpGet.setHeader(HttpHeader.AUTHORIZATION.asString(), "Basic " + authBase64Code);
115118
httpclient.execute(httpGet);
116119

117120
Assert.assertFalse(isAuthorized(httpCookieStore.getCookies()));

0 commit comments

Comments
 (0)