Skip to content

Conversation

@HiuKwok
Copy link
Contributor

@HiuKwok HiuKwok commented Mar 13, 2024

What changes were proposed in this pull request?

This is a draft MR to upgrade Jetty deps from 11 to 12.

Why are the changes needed?

Does this PR introduce any user-facing change?

How was this patch tested?

Was this patch authored or co-authored using generative AI tooling?

@HiuKwok
Copy link
Contributor Author

HiuKwok commented Mar 13, 2024

This is a draft MR and I'm still working on it.

@HiuKwok
Copy link
Contributor Author

HiuKwok commented Mar 13, 2024

@dongjoon-hyun @LuciferYang

During the past few weeks, I managed to re-write / update, all Jetty-related classes, things look fine in most of the Java / Scala classes.
However, due to the new handler class structure that Jetty 12 introduced, I'm not sure is that feasible to replicate what ProxyRedirectHandler is performing now.

If I understand correctly the initial intent of ProxyRedirectHandler is to override the redirect behaviour, in the case that Jetty decides to redirect the given request, BEFORE the request reaches any of the servlets.

However in Jetty 12, all Jetty handlers are switched to use the Jetty Request and Response wrapper object, hence it's no longer possible to override the redirect behaviour via the sendRedirect method call.

I have checked on the Jetty upgrade guide, which the guide suggests that all sendDirect() should be rewritten with Response.sendRedirect(request, response, callback, location).
However in this case we no longer have to control URL rewrite, because this is a static method from Jetty lib.

I wonder if you guys have an idea on this / or if any visible alternative can be implemented instead?

import org.apache.spark.scheduler._
import org.apache.spark.util.{SparkTestUtils, Utils}


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this kind of empty lines to minimize your PR.

val handlers = new HandlerList()
handlers.setHandlers(Array[Handler](resHandler, new DefaultHandler()))
resHandler.setBaseResource(ResourceFactory.of(resHandler).newResource(resBaseDir))
val handlers = new Handler.Sequence;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the Scala style. We don't need ; at the end.

// Make sure we don't end up with "//" in the middle
val newUrl = new URL(new URL(request.getRequestURL.toString), prefixedDestPath).toString
response.sendRedirect(newUrl)
// Response.sendRedirect(request, response, callback, location)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clean up this leftover.

override def filterServerResponseHeader(
clientRequest: HttpServletRequest,
serverResponse: Response,
serverResponse: org.eclipse.jetty.client.Response,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use import statement. If there is a conflict, you can use Scala's import renaming feature like JMap usage.

if (headerName.equalsIgnoreCase("location")) {
val newHeader = createProxyLocationHeader(headerValue, clientRequest,
serverResponse.getRequest().getURI())
serverResponse.getRequest.getURI)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this change really? Otherwise, please revert all this kind of style change.

// val proxyUri = _proxyUri.stripSuffix("/")
//
// }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clean up this left-over.

// }
// super.sendRedirect(newTarget)
// }
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this leftover.

}
isBindCollision(e.getCause)
case e: MultiException =>
e.getThrowables.asScala.exists(isBindCollision)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a nice removal.

test("SPARK-45522: Jetty 10 and above shouuld return status code 302 with correct redirect url" +
" when request URL ends with a context path without trailing '/'") {
test("SPARK-34449: Jetty 9.4.35.v20201120 and later no longer return status code 302 " +
" and handle internally when request URL ends with a context path without trailing '/'") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why do we change this in this PR. Could you spin-off this in order to merge before this PR?

int maxMessageSize = hiveConf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_MAX_MESSAGE_SIZE);
int requestTimeout = (int) hiveConf.getTimeVar(
HiveConf.ConfVars.HIVE_SERVER2_THRIFT_LOGIN_TIMEOUT, TimeUnit.SECONDS);
HiveConf.ConfVars.HIVE_SERVER2_THRIFT_LOGIN_TIMEOUT, TimeUnit.SECONDS);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a mistake. Please revert this file's changes.

@dongjoon-hyun
Copy link
Member

Thank you for sharing your AS-IS status, @HiuKwok .

For the following, it's a little surprising to me.

However in this case we no longer have to control URL rewrite, because this is a static method from Jetty lib.

@dongjoon-hyun
Copy link
Member

Hi, @HiuKwok . If Jetty 12 is missing the URL rewrite feature and we cannot use it, it's okay to add some comments and stop this migration effort.

@HiuKwok
Copy link
Contributor Author

HiuKwok commented Mar 20, 2024

@dongjoon-hyun Sure thing, let me revisit this and do it accordingly.

@HiuKwok
Copy link
Contributor Author

HiuKwok commented Mar 21, 2024

Left a comment on the Jira ticket and I'm closing this MR for now.

@HiuKwok HiuKwok closed this Mar 21, 2024
@dongjoon-hyun
Copy link
Member

Thank you for all of your contributions here, @HiuKwok !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants