Skip to content

Upgrade org.eclipse.jetty to 12.1.10 - #365

Open
yashas-cs wants to merge 1 commit into
data-integrations:developfrom
cloudsufi:feature/upgrade-jetty-12
Open

Upgrade org.eclipse.jetty to 12.1.10#365
yashas-cs wants to merge 1 commit into
data-integrations:developfrom
cloudsufi:feature/upgrade-jetty-12

Conversation

@yashas-cs

Copy link
Copy Markdown

Summary

Upgrades org.eclipse.jetty dependencies from 9.4.x to 12.1.10 in pom.xml, excludes outdated transitive Jetty dependencies, and updates codebase to adhere to Jetty 12 API changes.

Key Changes

  1. Dependency Management & Upgrades (pom.xml):

    • Added <jetty.version>12.1.10</jetty.version> to <properties>.
    • Updated jetty-http and explicitly added jetty-client and jetty-util dependencies with ${jetty.version}.
    • Excluded older transitive 9.4.12.v20180830 Jetty artifacts from cometd-java-client.
    • Excluded legacy Jetty 8 / Orbit artifacts from hydrator-test.
  2. Jetty 12 API Migrations:

    • Authenticator.java & SalesforceQueryUtil.java:
      • Updated imports from org.eclipse.jetty.client.api.* to org.eclipse.jetty.client.*.
      • Replaced new HttpClient(SslContextFactory) with default new HttpClient().
      • Updated fluent header calls to use Request.headers(...).
    • SalesforcePushTopicListener.java:
      • Registered OAuth header customization using httpClient.getRequestListeners().addListener(...) with Request.Listener instead of overriding deprecated LongPollingTransport.customize(Request).
    • SalesforceQueryUtilTest.java:
      • Updated Mockito / PowerMock expectations to match Jetty 12 HttpClient initialization and headers.

Verification

  • Verified dependency tree via mvn dependency:tree -Dincludes=org.eclipse.jetty* to ensure no legacy 9.4.x artifacts remain in compile scope.
  • Verified compilation via mvn compile (BUILD SUCCESS).

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request upgrades Jetty to version 12.1.10 and refactors the codebase to adapt to Jetty 12 APIs. However, several critical issues have been identified. In Jetty 12, SslContextFactory is abstract, and instantiating HttpClient with the default constructor will fail to configure SSL/TLS, causing HTTPS requests to Salesforce to fail. Additionally, excluding Jetty 9.4.x transitive dependencies while using CometD 4.x will result in runtime compatibility errors, as CometD 4.x is not compatible with Jetty 12 APIs.

import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.client.Request;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

Import the SslContextFactory class to configure SSL/TLS support for the HttpClient.

Suggested change
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.util.ssl.SslContextFactory;


SslContextFactory sslContextFactory = new SslContextFactory();
HttpClient httpClient = new HttpClient(sslContextFactory);
HttpClient httpClient = new HttpClient();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

In Jetty 12, SslContextFactory is abstract, and the default constructor new HttpClient() does not configure SSL/TLS support. Since Salesforce APIs strictly require HTTPS, using new HttpClient() without an explicit SslContextFactory.Client will cause all requests to fail with an exception (e.g., IllegalStateException: Scheme-specific transport not found: https). To fix this, instantiate HttpClient with an instance of SslContextFactory.Client.

Suggested change
HttpClient httpClient = new HttpClient();
SslContextFactory.Client sslContextFactory = new SslContextFactory.Client();
HttpClient httpClient = new HttpClient(sslContextFactory);

import org.eclipse.jetty.client.ProxyConfiguration;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.client.Request;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

Import the SslContextFactory class to configure SSL/TLS support for the HttpClient.

Suggested change
import org.eclipse.jetty.client.Request;
import org.eclipse.jetty.client.Request;
import org.eclipse.jetty.util.ssl.SslContextFactory;


SslContextFactory sslContextFactory = new SslContextFactory();
HttpClient httpClient = new HttpClient(sslContextFactory);
HttpClient httpClient = new HttpClient();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

In Jetty 12, SslContextFactory is abstract, and the default constructor new HttpClient() does not configure SSL/TLS support. Since Salesforce APIs strictly require HTTPS, using new HttpClient() without an explicit SslContextFactory.Client will cause all requests to fail with an exception (e.g., IllegalStateException: Scheme-specific transport not found: https). To fix this, instantiate HttpClient with an instance of SslContextFactory.Client.

Suggested change
HttpClient httpClient = new HttpClient();
SslContextFactory.Client sslContextFactory = new SslContextFactory.Client();
HttpClient httpClient = new HttpClient(sslContextFactory);

import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.client.Request;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

Import the SslContextFactory class to configure SSL/TLS support for the HttpClient.

Suggested change
import org.eclipse.jetty.client.Request;
import org.eclipse.jetty.client.Request;
import org.eclipse.jetty.util.ssl.SslContextFactory;


// Set up a Jetty HTTP client to use with CometD
HttpClient httpClient = new HttpClient(sslContextFactory);
HttpClient httpClient = new HttpClient();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

In Jetty 12, SslContextFactory is abstract, and the default constructor new HttpClient() does not configure SSL/TLS support. Since Salesforce APIs strictly require HTTPS, using new HttpClient() without an explicit SslContextFactory.Client will cause all requests to fail with an exception (e.g., IllegalStateException: Scheme-specific transport not found: https). To fix this, instantiate HttpClient with an instance of SslContextFactory.Client.

Suggested change
HttpClient httpClient = new HttpClient();
SslContextFactory.Client sslContextFactory = new SslContextFactory.Client();
HttpClient httpClient = new HttpClient(sslContextFactory);

import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.client.Request;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

Import the SslContextFactory class to configure SSL/TLS support for the mocked HttpClient.

Suggested change
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.util.ssl.SslContextFactory;

Comment on lines +298 to 299
PowerMockito.whenNew(HttpClient.class).withNoArguments()
.thenReturn(httpClient);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

Since SalesforceQueryUtil needs to instantiate HttpClient with SslContextFactory.Client to support HTTPS, update the PowerMockito expectation to match the constructor call with arguments.

Suggested change
PowerMockito.whenNew(HttpClient.class).withNoArguments()
.thenReturn(httpClient);
PowerMockito.whenNew(HttpClient.class).withArguments(Mockito.any(SslContextFactory.Client.class))
.thenReturn(httpClient);

Comment thread pom.xml
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
</exclusion>
<exclusion>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Excluding Jetty 9.4.x transitive dependencies from cometd-java-client version 4.0.0 and forcing it to run with Jetty 12 will cause critical runtime failures (such as NoClassDefFoundError or NoSuchMethodError). CometD 4.x is compiled against Jetty 9.4.x APIs (e.g., it references org.eclipse.jetty.client.api.Request which has been refactored/removed in Jetty 12). To support Jetty 12, you must upgrade cometd-java-client to a compatible version (such as CometD 7.x or 8.x depending on the Jakarta EE namespace used by the project).

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants