Skip to content

fix: add @JvmOverloads to OutboxProcessor constructor#75

Merged
rawo merged 3 commits into
mainfrom
feature/outbox-processor-jvmoverloads
Jul 17, 2026
Merged

fix: add @JvmOverloads to OutboxProcessor constructor#75
rawo merged 3 commits into
mainfrom
feature/outbox-processor-jvmoverloads

Conversation

@endrju19

@endrju19 endrju19 commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Fixes #74.

Problem

OutboxProcessor's constructor lacked @JvmOverloads, so its defaulted listener and clock parameters were invisible to Java — a Java caller could no longer use new OutboxProcessor(store, entryProcessor) and had to pass all four arguments. OutboxScheduler and OutboxPurger already have @JvmOverloads; OutboxProcessor was missed when listener/clock were added.

Change

  • Add @JvmOverloads to the OutboxProcessor constructor (one line, backward-compatible — Kotlin call sites unaffected).
  • Add a Java interop guard: JavaOutboxProcessorConstruction.java calls the shorter constructors and is driven by OutboxProcessorJavaInteropTest. This tests the real contract — the Java source compiling — rather than a runtime reflection proxy. okapi-core had no Java interop test at all, which is why this regressed unnoticed; the guard also doubles as Java usage documentation.

Verification

  • Positive: ./gradlew clean ktlintFormat :okapi-core:test → BUILD SUCCESSFUL, interop test green; full :okapi-core:test green.
  • Negative (proves the guard bites): temporarily removing @JvmOverloads fails compileTestJava with constructor OutboxProcessor cannot be applied to given types; required: OutboxStore,OutboxEntryProcessor,OutboxProcessorListener,Clock; found: OutboxStore,OutboxEntryProcessor.

Out of scope

transactionRunner becoming required on OutboxScheduler/OutboxPurger is a deliberate, correct design change and is intentionally not touched here.

endrju19 added 2 commits July 17, 2026 11:00
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.
@rawo rawo self-assigned this Jul 17, 2026
@rawo
rawo requested a review from Copilot July 17, 2026 10:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 @JvmOverloads to OutboxProcessor’s primary constructor so Java can omit trailing default parameters.
  • Add a Java helper (JavaOutboxProcessorConstruction) that exercises the shorter constructors to force compileTestJava to 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>
@rawo
rawo merged commit 1bb5583 into main Jul 17, 2026
8 checks passed
@rawo
rawo deleted the feature/outbox-processor-jvmoverloads branch July 17, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OutboxProcessor constructor is missing @JvmOverloads (Java interop regression)

3 participants