Skip to content

Commit 66ee0a6

Browse files
authored
HADOOP-17371. Bump Jetty to the latest version 9.4.34. Contributed by Wei-Chiu Chuang. (#2453)
1 parent 2825d06 commit 66ee0a6

File tree

7 files changed

+67
-13
lines changed

7 files changed

+67
-13
lines changed

hadoop-client-modules/hadoop-client-minicluster/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,18 @@
840840
<exclude>*/**</exclude>
841841
</excludes>
842842
</filter>
843+
<filter>
844+
<artifact>org.eclipse.jetty:jetty-util-ajax</artifact>
845+
<excludes>
846+
<exclude>*/**</exclude>
847+
</excludes>
848+
</filter>
849+
<filter>
850+
<artifact>org.eclipse.jetty:jetty-server</artifact>
851+
<excludes>
852+
<exclude>jetty-dir.css</exclude>
853+
</excludes>
854+
</filter>
843855
</filters>
844856

845857
<!-- relocate classes from mssql-jdbc -->

hadoop-common-project/hadoop-auth/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@
193193
<artifactId>guava</artifactId>
194194
<scope>test</scope>
195195
</dependency>
196+
<dependency>
197+
<groupId>org.eclipse.jetty</groupId>
198+
<artifactId>jetty-server</artifactId>
199+
</dependency>
196200
</dependencies>
197201

198202
<build>

hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/server/AuthenticationFilter.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.apache.hadoop.security.authentication.client.AuthenticationException;
2020
import org.apache.hadoop.security.authentication.client.KerberosAuthenticator;
2121
import org.apache.hadoop.security.authentication.util.*;
22+
import org.eclipse.jetty.server.Response;
2223
import org.slf4j.Logger;
2324
import org.slf4j.LoggerFactory;
2425

@@ -619,11 +620,20 @@ && getMaxInactiveInterval() > 0) {
619620
KerberosAuthenticator.WWW_AUTHENTICATE))) {
620621
errCode = HttpServletResponse.SC_FORBIDDEN;
621622
}
623+
// After Jetty 9.4.21, sendError() no longer allows a custom message.
624+
// use setStatusWithReason() to set a custom message.
625+
String reason;
622626
if (authenticationEx == null) {
623-
httpResponse.sendError(errCode, "Authentication required");
627+
reason = "Authentication required";
624628
} else {
625-
httpResponse.sendError(errCode, authenticationEx.getMessage());
629+
reason = authenticationEx.getMessage();
626630
}
631+
632+
if (httpResponse instanceof Response) {
633+
((Response)httpResponse).setStatusWithReason(errCode, reason);
634+
}
635+
636+
httpResponse.sendError(errCode, reason);
627637
}
628638
}
629639
}

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/http/RestCsrfPreventionFilter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.apache.hadoop.classification.InterfaceStability;
3838
import org.apache.hadoop.conf.Configuration;
3939

40+
import org.eclipse.jetty.server.Response;
4041
import org.slf4j.Logger;
4142
import org.slf4j.LoggerFactory;
4243

@@ -271,6 +272,10 @@ public void proceed() throws IOException, ServletException {
271272

272273
@Override
273274
public void sendError(int code, String message) throws IOException {
275+
if (httpResponse instanceof Response) {
276+
((Response)httpResponse).setStatusWithReason(code, message);
277+
}
278+
274279
httpResponse.sendError(code, message);
275280
}
276281
}

hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSAuthenticationFilter.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticationHandler;
2929
import org.apache.hadoop.security.token.delegation.web.KerberosDelegationTokenAuthenticationHandler;
3030
import org.apache.hadoop.security.token.delegation.web.PseudoDelegationTokenAuthenticationHandler;
31+
import org.eclipse.jetty.server.Response;
3132

3233
import javax.servlet.FilterChain;
3334
import javax.servlet.FilterConfig;
@@ -113,6 +114,18 @@ public void setStatus(int sc) {
113114
public void sendError(int sc, String msg) throws IOException {
114115
statusCode = sc;
115116
this.msg = msg;
117+
118+
ServletResponse response = getResponse();
119+
120+
// After Jetty 9.4.21, sendError() no longer allows a custom message.
121+
// use setStatusWithReason() to set a custom message.
122+
if (response instanceof Response) {
123+
((Response) response).setStatusWithReason(sc, msg);
124+
} else {
125+
KMS.LOG.warn("The wrapped response object is instance of {}" +
126+
", not org.eclipse.jetty.server.Response. Can't set custom error " +
127+
"message", response.getClass());
128+
}
116129
super.sendError(sc, HtmlQuoting.quoteHtmlChars(msg));
117130
}
118131

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ImageServlet.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.apache.hadoop.hdfs.DFSConfigKeys;
4343
import org.apache.hadoop.hdfs.DFSUtilClient;
4444
import org.apache.hadoop.security.SecurityUtil;
45+
import org.eclipse.jetty.server.Response;
4546
import org.slf4j.Logger;
4647
import org.slf4j.LoggerFactory;
4748
import org.apache.hadoop.classification.InterfaceAudience;
@@ -119,7 +120,7 @@ private FSImage getAndValidateFSImage(ServletContext context,
119120
if (nnImage == null) {
120121
String errorMsg = "NameNode initialization not yet complete. "
121122
+ "FSImage has not been set in the NameNode.";
122-
response.sendError(HttpServletResponse.SC_FORBIDDEN, errorMsg);
123+
sendError(response, HttpServletResponse.SC_FORBIDDEN, errorMsg);
123124
throw new IOException(errorMsg);
124125
}
125126
return nnImage;
@@ -218,7 +219,7 @@ private void serveFile(File file) throws IOException {
218219

219220
} catch (Throwable t) {
220221
String errMsg = "GetImage failed. " + StringUtils.stringifyException(t);
221-
response.sendError(HttpServletResponse.SC_GONE, errMsg);
222+
sendError(response, HttpServletResponse.SC_GONE, errMsg);
222223
throw new IOException(errMsg);
223224
} finally {
224225
response.getOutputStream().close();
@@ -234,7 +235,7 @@ private void validateRequest(ServletContext context, Configuration conf,
234235
conf)) {
235236
String errorMsg = "Only Namenode, Secondary Namenode, and administrators may access "
236237
+ "this servlet";
237-
response.sendError(HttpServletResponse.SC_FORBIDDEN, errorMsg);
238+
sendError(response, HttpServletResponse.SC_FORBIDDEN, errorMsg);
238239
LOG.warn("Received non-NN/SNN/administrator request for image or edits from "
239240
+ request.getUserPrincipal().getName()
240241
+ " at "
@@ -247,7 +248,7 @@ private void validateRequest(ServletContext context, Configuration conf,
247248
&& !myStorageInfoString.equals(theirStorageInfoString)) {
248249
String errorMsg = "This namenode has storage info " + myStorageInfoString
249250
+ " but the secondary expected " + theirStorageInfoString;
250-
response.sendError(HttpServletResponse.SC_FORBIDDEN, errorMsg);
251+
sendError(response, HttpServletResponse.SC_FORBIDDEN, errorMsg);
251252
LOG.warn("Received an invalid request file transfer request "
252253
+ "from a secondary with storage info " + theirStorageInfoString);
253254
throw new IOException(errorMsg);
@@ -578,7 +579,7 @@ public Void run() throws Exception {
578579
// we need a different response type here so the client can differentiate this
579580
// from the failure to upload due to (1) security, or (2) other checkpoints already
580581
// present
581-
response.sendError(HttpServletResponse.SC_EXPECTATION_FAILED,
582+
sendError(response, HttpServletResponse.SC_EXPECTATION_FAILED,
582583
"Nameode "+request.getLocalAddr()+" is currently not in a state which can "
583584
+ "accept uploads of new fsimages. State: "+state);
584585
return null;
@@ -593,15 +594,15 @@ public Void run() throws Exception {
593594
// if the node is attempting to upload an older transaction, we ignore it
594595
SortedSet<ImageUploadRequest> larger = currentlyDownloadingCheckpoints.tailSet(imageRequest);
595596
if (larger.size() > 0) {
596-
response.sendError(HttpServletResponse.SC_CONFLICT,
597+
sendError(response, HttpServletResponse.SC_CONFLICT,
597598
"Another checkpointer is already in the process of uploading a" +
598599
" checkpoint made up to transaction ID " + larger.last());
599600
return null;
600601
}
601602

602603
//make sure no one else has started uploading one
603604
if (!currentlyDownloadingCheckpoints.add(imageRequest)) {
604-
response.sendError(HttpServletResponse.SC_CONFLICT,
605+
sendError(response, HttpServletResponse.SC_CONFLICT,
605606
"Either current namenode is checkpointing or another"
606607
+ " checkpointer is already in the process of "
607608
+ "uploading a checkpoint made at transaction ID "
@@ -648,7 +649,7 @@ public Void run() throws Exception {
648649
(txid - lastCheckpointTxid) + " expecting at least "
649650
+ checkpointTxnCount;
650651
LOG.info(message);
651-
response.sendError(HttpServletResponse.SC_CONFLICT, message);
652+
sendError(response, HttpServletResponse.SC_CONFLICT, message);
652653
return null;
653654
}
654655

@@ -658,7 +659,7 @@ public Void run() throws Exception {
658659
+ "another checkpointer already uploaded an "
659660
+ "checkpoint for txid " + txid;
660661
LOG.info(message);
661-
response.sendError(HttpServletResponse.SC_CONFLICT, message);
662+
sendError(response, HttpServletResponse.SC_CONFLICT, message);
662663
return null;
663664
}
664665

@@ -695,11 +696,20 @@ public Void run() throws Exception {
695696
});
696697
} catch (Throwable t) {
697698
String errMsg = "PutImage failed. " + StringUtils.stringifyException(t);
698-
response.sendError(HttpServletResponse.SC_GONE, errMsg);
699+
sendError(response, HttpServletResponse.SC_GONE, errMsg);
699700
throw new IOException(errMsg);
700701
}
701702
}
702703

704+
private void sendError(HttpServletResponse response, int code, String message)
705+
throws IOException {
706+
if (response instanceof Response) {
707+
((Response)response).setStatusWithReason(code, message);
708+
}
709+
710+
response.sendError(code, message);
711+
}
712+
703713
/*
704714
* Params required to handle put image request
705715
*/

hadoop-project/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<!--Whether to proceed to next module if any test failures exist-->
3838
<ignoreTestFailure>true</ignoreTestFailure>
3939
<maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
40-
<jetty.version>9.4.20.v20190813</jetty.version>
40+
<jetty.version>9.4.35.v20201120</jetty.version>
4141
<test.exclude>_</test.exclude>
4242
<test.exclude.pattern>_</test.exclude.pattern>
4343

0 commit comments

Comments
 (0)