Update Netty 4.1→4.2 and companion dependency upgrades#237
Open
usmansaleem wants to merge 1 commit into
Open
Conversation
Dependency version bumps: - Netty 4.1.115.Final → 4.2.15.Final - Guava 33.2.1-jre → 33.6.0-jre - Log4j 2.23.1 → 2.26.0 - BouncyCastle 1.78.1 → 1.84 - Vert.x 4.5.9 → 4.5.28 - Tuweni 2.7.0 → 2.7.2 - Add org.jspecify:jspecify:1.0.0 (compileOnly) Fix deprecations introduced by these upgrades: Netty 4.2: - Replace NioEventLoopGroup with MultiThreadIoEventLoopGroup + NioIoHandler - Replace InternetProtocolFamily with java.net.StandardProtocolFamily Reactor 3.5+: - Migrate ReplayProcessor/FluxProcessor/FluxSink to Sinks.many().replay().latest() - PipelineImpl.push() uses emitNext with FAIL_NON_SERIALIZED retry to handle concurrent emissions from IPv4 and IPv6 Netty event-loop threads - Suppress deprecated Scheduler.start() override in DelegatingReactorScheduler JSpecify (replacing javax.annotation removed by Netty 4.2 transitive dep): - Replace @nonnull with @nonnull from org.jspecify.annotations Guava: - Replace CacheBuilder.expireAfterWrite(long, TimeUnit) with expireAfterWrite(Duration)
There was a problem hiding this comment.
Pull request overview
This PR upgrades core networking and supporting dependencies (notably Netty 4.1→4.2) and updates the discovery networking/reactive plumbing to match new APIs and remove deprecations, including the migration from Reactor ReplayProcessor/FluxSink to Sinks.Many and adoption of JSpecify annotations.
Changes:
- Upgrade Netty (4.1→4.2) and companion libraries (Guava, Log4j, BouncyCastle, Vert.x, Tuweni), plus add
org.jspecify:jspecifyascompileOnly. - Replace deprecated Reactor processors/sinks with
Sinks.many().replay().latest()across pipeline, networking, and scheduler utilities. - Replace Netty
InternetProtocolFamilyusage withjava.net.StandardProtocolFamilymapping helpers.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/org/ethereum/beacon/discovery/pipeline/handler/OutgoingParcelHandlerTest.java | Updates test to mock Sinks.Many instead of FluxSink and verify emission via Reactor sinks API. |
| src/main/java/org/ethereum/beacon/discovery/scheduler/SimpleProcessor.java | Migrates from ReplayProcessor/FluxSink to Sinks.Many for a lightweight processor abstraction. |
| src/main/java/org/ethereum/beacon/discovery/scheduler/ErrorHandlingScheduler.java | Switches @Nonnull to JSpecify @NonNull on scheduler APIs. |
| src/main/java/org/ethereum/beacon/discovery/scheduler/DelegatingReactorScheduler.java | Switches @Nonnull to JSpecify @NonNull and suppresses deprecated start() override. |
| src/main/java/org/ethereum/beacon/discovery/pipeline/PipelineImpl.java | Migrates pipeline source from ReplayProcessor to Sinks.Many with non-serialized emission retry. |
| src/main/java/org/ethereum/beacon/discovery/pipeline/handler/OutgoingParcelHandler.java | Migrates outgoing parcel emission from FluxSink.next to Sinks.Many.tryEmitNext. |
| src/main/java/org/ethereum/beacon/discovery/network/NettyDiscoveryServerImpl.java | Updates Netty event loop initialization for Netty 4.2 and replaces inbound processor with Sinks.Many. |
| src/main/java/org/ethereum/beacon/discovery/network/NettyDiscoveryClientImpl.java | Replaces InternetProtocolFamily channel selection with StandardProtocolFamily helper. |
| src/main/java/org/ethereum/beacon/discovery/network/IncomingMessageSink.java | Updates inbound Netty handler to emit into Sinks.Many instead of FluxSink. |
| src/main/java/org/ethereum/beacon/discovery/DiscoverySystemBuilder.java | Updates listen-address validation to use StandardProtocolFamily instead of Netty’s InternetProtocolFamily. |
| src/main/java/org/ethereum/beacon/discovery/DiscoveryManagerImpl.java | Migrates outgoing message stream to Sinks.Many, updates client wiring, and uses StandardProtocolFamily for channel map keys. |
| src/main/java/org/ethereum/beacon/discovery/database/ExpirationSet.java | Migrates Guava cache expiration API to Duration overload. |
| gradle/versions.gradle | Bumps Netty/Guava/Log4j/BouncyCastle/Vert.x/Tuweni versions and adds managed JSpecify dependency. |
| build.gradle | Adds compileOnly org.jspecify:jspecify to support JSpecify annotations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+53
to
54
| outgoingSink.tryEmitNext(parcel); | ||
| envelope.remove(Field.INCOMING); |
| protected void channelRead0(ChannelHandlerContext ctx, Envelope msg) { | ||
| LOG.trace(() -> String.format("Incoming packet %s in session %s", msg, ctx)); | ||
| messageSink.next(msg); | ||
| messageSink.tryEmitNext(msg); |
Comment on lines
69
to
72
| @Override | ||
| public void onNext(T t) { | ||
| sink.next(t); | ||
| sinks.tryEmitNext(t); | ||
| } |
Comment on lines
75
to
77
| public void onError(Throwable throwable) { | ||
| sink.error(throwable); | ||
| sinks.tryEmitError(throwable); | ||
| } |
Comment on lines
79
to
82
| @Override | ||
| public void onComplete() { | ||
| sink.complete(); | ||
| sinks.tryEmitComplete(); | ||
| } |
Comment on lines
56
to
+58
| handler.handle(envelope); | ||
|
|
||
| verify(outgoingSink).next(parcel); | ||
| verify(outgoingSink).tryEmitNext(parcel); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
org.jspecify:jspecify:1.0.0(compileOnly) to replacejavax.annotation.Nonnullwhich was previously provided transitively by Netty 4.1 but dropped in 4.2 (aligns with Besu's migration to JSpecify)ReplayProcessor→Sinks, NettyNioEventLoopGroup→MultiThreadIoEventLoopGroup,InternetProtocolFamily→java.net.StandardProtocolFamily, GuavaCacheBuilderduration overload)Details
Netty 4.2 deprecations
NioEventLoopGroup→MultiThreadIoEventLoopGroup(1, NioIoHandler.newFactory())inNettyDiscoveryServerImplInternetProtocolFamily→java.net.StandardProtocolFamilyinNettyDiscoveryClientImpl,DiscoveryManagerImpl,DiscoverySystemBuilderReactor Sinks migration (
ReplayProcessor/FluxProcessor/FluxSinkdeprecated since Reactor 3.5)ReplayProcessor.cacheLast()+FluxSink→Sinks.many().replay().latest()acrossNettyDiscoveryServerImpl,DiscoveryManagerImpl,PipelineImpl,SimpleProcessor,IncomingMessageSink,OutgoingParcelHandlerPipelineImpl.push()usesemitNextwithFAIL_NON_SERIALIZEDretry rather thantryEmitNext— necessary becauseincomingPipelinecan receive concurrent pushes from IPv4 and IPv6 Netty event-loop threads; the oldReplayProcessor.FluxSinkserialized these internally, the new safeSinks.Manydoes notDelegatingReactorScheduler.start(): suppress deprecated override (preserves delegation behaviour for downstream schedulers)Other
CacheBuilder.expireAfterWrite(long, TimeUnit)→expireAfterWrite(Duration)inExpirationSet@Nonnull→@NonNull(JSpecify) inDelegatingReactorScheduler,ErrorHandlingSchedulerTest plan
./gradlew buildpasses (all 16 integration tests green)./gradlew compileJava --rerun-taskswith-Xlint:deprecationproduces zero deprecation warningsNote
Medium Risk
Touches discovery UDP I/O and reactive pipelines with concurrency-sensitive
PipelineImplemit behavior; dependency major bumps (Netty 4.2) increase regression risk in networking despite targeted API migrations.Overview
Upgrades Netty 4.1 → 4.2.15 and bumps Guava, Log4j, BouncyCastle, Vert.x, and Tuweni. Adds
org.jspecify:jspecify(compileOnly) because Netty 4.2 no longer bringsjavax.annotationtransitively.Netty 4.2:
NettyDiscoveryServerImplusesMultiThreadIoEventLoopGroup+NioIoHandlerinstead ofNioEventLoopGroup. IPv4/IPv6 channel maps and listen validation usejava.net.StandardProtocolFamily(with a sharedprotocolFamilyOfhelper) instead of Netty’sInternetProtocolFamily.Reactor: Deprecated
ReplayProcessor/FluxSinkpaths are replaced withSinks.many().replay().latest()for incoming/outgoing UDP streams, pipelines, andSimpleProcessor.PipelineImpl.push()usesemitNextwithFAIL_NON_SERIALIZEDretry so concurrent pushes from dual-stack Netty event loops stay safe. Emit sites usetryEmitNext/asFlux()where appropriate.Misc:
ExpirationSetuses Guava’sexpireAfterWrite(Duration); scheduler wrappers use JSpecify@NonNull; tests mockSinks.Manyand verifytryEmitNext.Reviewed by Cursor Bugbot for commit f1ed571. Bugbot is set up for automated code reviews on this repo. Configure here.