apache / apache/seatunnel

[Improve][Engine] Migrate JobEventHttpReportHandler from the EOL okhttp 2.x to the already-managed okhttp3 4.12.0

Open
#11,656 2 comments 0 reactions 0 assignees View on GitHub
feature
Dominant language
Java
Stars
9.7k
Forks
2.4k
Avg merge
3d 9h
Merged PRs (30d)
204

Description

### Search before asking

- [X] I had searched in the [issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22feature%22) and found no similar feature requirement.

### Description

`org.apache.seatunnel.engine.server.event.JobEventHttpReportHandler` is written against the legacy **okhttp 2.x** API — `com.squareup.okhttp.*`, which is a different groupId *and* a different Java package from the `com.squareup.okhttp3:okhttp` 4.12.0 already managed in the root pom.

Until now `seatunnel-engine-server` never declared okhttp: the classes arrived transitively from `hadoop-hdfs-client`, which depended on `com.squareup.okhttp:okhttp` 2.7.5 up to Hadoop 3.1.4, moved to `okhttp3` in 3.3.6, and ships neither in 3.4.x. #11648 (shaded Hadoop 3.1.4 → 3.4.3) therefore has to declare `com.squareup.okhttp:okhttp:2.7.5` explicitly, or `JobEventHttpReportHandler` fails at runtime with `NoClassDefFoundError`.

That declaration is correct and necessary, but it has a side effect worth fixing separately: SeaTunnel now **ships** okhttp 2.7.5 — released in 2016, end-of-life for years — where previously it only borrowed the classes from Hadoop. Since the root pom already manages okhttp3 4.12.0, and several connectors (`connector-graphql`, `connector-typesense`, `connector-influxdb`, `seatunnel-transforms-v2`) already use it, migrating this one handler removes a long-lived unmaintained dependency from the distribution.

@DanielLeens suggested opening this as a follow-up while reviewing #11648, on the reasoning that porting the handler inside a dependency-upgrade PR would make both changes harder to review and harder to revert. I agree, hence the separate issue.

### Scope

Three files reference the okhttp 2.x API:

- `seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/event/JobEventHttpReportHandler.java` (main)
- `seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/event/JobEventHttpReportHandlerTest.java`
- `seatunnel-e2e/seatunnel-engine-e2e/connector-console-seatunnel-e2e/src/test/java/org/apache/seatunnel/engine/e2e/console/FakeSourceToConsoleWithEventReportIT.java`

Work involved:

1. Port the handler to `okhttp3` (`OkHttpClient`, `Request`, `RequestBody`, `MediaType`, `Response` — the shapes are similar but `RequestBody.create` argument order and the `Call`/`Response` lifecycle differ).
2. Swap the test-scoped `com.squareup.okhttp:mockwebserver` 2.7.5 for `com.squareup.okhttp3:mockwebserver`, which the root pom already manages at the same version as okhttp3.
3. Drop the explicit `com.squareup.okhttp:okhttp` 2.7.5 declaration that #11648 adds to `seatunnel-engine-server`, and the corresponding `known-dependencies.txt` / `release-docs/LICENSE` entries.
4. Check `connector-console-seatunnel-e2e`'s own test-scoped `com.squareup.okhttp` declaration.

This should be behaviour-preserving for HTTP event reporting; it is worth confirming that timeout and connection-pool defaults are set explicitly rather than inherited, since okhttp3's defaults differ from 2.x.

### Are you willing to submit a PR?

- [X] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)

Contributor guide

No contributing guide indexed for this repository

Research direction

Read JobEventHttpReportHandler.java and its named unit and console E2E tests, then compare their current okhttp 2.x usage with the okhttp3 version managed in the root pom. Run JobEventHttpReportHandlerTest.java and the referenced E2E test while checking the engine and connector-console dependency declarations. Done means HTTP event reporting remains behaviorally equivalent, okhttp 2.x declarations and metadata entries are removed, and timeout and connection-pool settings are explicit.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, build-system, testing
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
66/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.