fix: add @JvmOverloads to OutboxProcessor constructor#75
Merged
Conversation
The defaulted listener and clock parameters were invisible to Java, so Java callers could no longer use the 2-arg form new OutboxProcessor(store, entryProcessor). Restore the Java-visible overloads and guard them with a reflection-based test (okapi-core had no Java interop tests, which is why this slipped).
Replace the reflection-based check with a Java source (JavaOutboxProcessor- Construction) that calls the shorter constructors, driven by the Kotest test. This tests the actual contract — Java source compiling — instead of a runtime proxy: dropping @jvmoverloads now fails compileTestJava (verified: 'constructor OutboxProcessor cannot be applied ... found: (store, entryProcessor)'). It's the idiomatic way to guard @jvm* interop and doubles as Java usage documentation.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR restores Java interop ergonomics for OutboxProcessor by generating Java-visible constructor overloads for defaulted parameters, and adds a compile-time Java guard test to prevent regressions in okapi-core.
Changes:
- Add
@JvmOverloadstoOutboxProcessor’s primary constructor so Java can omit trailing default parameters. - Add a Java helper (
JavaOutboxProcessorConstruction) that exercises the shorter constructors to forcecompileTestJavato fail if overloads disappear. - Add a Kotest wrapper (
OutboxProcessorJavaInteropTest) that runs the Java guard as part of the test suite.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| okapi-core/src/main/kotlin/com/softwaremill/okapi/core/OutboxProcessor.kt | Adds @JvmOverloads to the constructor to restore Java-visible overloads. |
| okapi-core/src/test/java/com/softwaremill/okapi/core/JavaOutboxProcessorConstruction.java | Java compile-time guard that uses the short OutboxProcessor constructors. |
| okapi-core/src/test/kotlin/com/softwaremill/okapi/core/OutboxProcessorJavaInteropTest.kt | Kotest that invokes the Java guard so the interop contract is exercised in CI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+32
to
+37
| deliverer = | ||
| object : MessageDeliverer { | ||
| override val type = "stub" | ||
|
|
||
| override fun deliver(entry: OutboxEntry) = DeliveryResult.Success | ||
| }, |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Rafał Wokacz <rafal.wokacz@gmail.com>
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.
Fixes #74.
Problem
OutboxProcessor's constructor lacked@JvmOverloads, so its defaultedlistenerandclockparameters were invisible to Java — a Java caller could no longer usenew OutboxProcessor(store, entryProcessor)and had to pass all four arguments.OutboxSchedulerandOutboxPurgeralready have@JvmOverloads;OutboxProcessorwas missed whenlistener/clockwere added.Change
@JvmOverloadsto theOutboxProcessorconstructor (one line, backward-compatible — Kotlin call sites unaffected).JavaOutboxProcessorConstruction.javacalls the shorter constructors and is driven byOutboxProcessorJavaInteropTest. This tests the real contract — the Java source compiling — rather than a runtime reflection proxy.okapi-corehad no Java interop test at all, which is why this regressed unnoticed; the guard also doubles as Java usage documentation.Verification
./gradlew clean ktlintFormat :okapi-core:test→ BUILD SUCCESSFUL, interop test green; full:okapi-core:testgreen.@JvmOverloadsfailscompileTestJavawithconstructor OutboxProcessor cannot be applied to given types; required: OutboxStore,OutboxEntryProcessor,OutboxProcessorListener,Clock; found: OutboxStore,OutboxEntryProcessor.Out of scope
transactionRunnerbecoming required onOutboxScheduler/OutboxPurgeris a deliberate, correct design change and is intentionally not touched here.