Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry and Repeat extensions functions require addons dependencies, but they are exported as optional and so not included #30

Open
agisbert opened this issue Feb 16, 2022 · 1 comment
Labels
status/has-workaround This has a known workaround described status/need-decision This issue needs a decision

Comments

@agisbert
Copy link

So this happened after I generated a project with spring initializer. https://start.spring.io/

I added the absolute minimum dependencies in it (see pic):

image

The outcome is the following dependencies in the pom file:

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-webflux</artifactId>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.module</groupId>
			<artifactId>jackson-module-kotlin</artifactId>
		</dependency>
		<dependency>
			<groupId>io.projectreactor.kotlin</groupId>
			<artifactId>reactor-kotlin-extensions</artifactId>
		</dependency>
		<dependency>
			<groupId>org.jetbrains.kotlin</groupId>
			<artifactId>kotlin-reflect</artifactId>
		</dependency>
		<dependency>
			<groupId>org.jetbrains.kotlin</groupId>
			<artifactId>kotlin-stdlib-jdk8</artifactId>
		</dependency>
		<dependency>
			<groupId>org.jetbrains.kotlinx</groupId>
			<artifactId>kotlinx-coroutines-reactor</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>io.projectreactor</groupId>
			<artifactId>reactor-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

Motivation

So, when using any of the extension functions for retry or repeats:

    fun postMovie(movie: Movie) =
        webClient
            .post()
            .uri("http://localhost:9009/movies")
            .body(Mono.just(movie))
            .retrieve()
            .toBodilessEntity()
            .retryExponentialBackoff(5, Duration.ofSeconds(1))
            .map {
                movie to true
            }.onErrorResume {
                println(it.message)
                Mono.just(movie to false)
            }

We get a nice NoClassDefFoundError:

java.lang.NoClassDefFoundError: reactor/retry/Retry
	at reactor.kotlin.extra.retry.RetryExtensionsKt.retryExponentialBackoff(RetryExtensions.kt:97) ~[reactor-kotlin-extensions-1.1.5.jar:1.1.5]
	at reactor.kotlin.extra.retry.RetryExtensionsKt.retryExponentialBackoff$default(RetryExtensions.kt:96) ~[reactor-kotlin-extensions-1.1.5.jar:1.1.5]

Desired solution

reactor-extra (optional "io.projectreactor.addons:reactor-extra:${reactorAddonsVersion}") is not an optional dependency but a compile one, same as reactor-core (compile "io.projectreactor:reactor-core:${reactorCoreVersion}"

Considered alternatives

  1. Not doing it?
  2. Refactor the extension functions so they make use of reactor-core Retry and Repeat classes (available since v3.3.3) (Probably more changes needed, haven't looked into it tbh).
@reactorbot reactorbot added the ❓need-triage This issue needs triage, hasn't been looked at by a team member yet label Feb 16, 2022
@simonbasle
Copy link
Member

simonbasle commented Feb 16, 2022

that would mean doing the same for reactor-test. and suddenly, depending on reactor-kotlin-extensions eg just for the toMono core parts enforces a dependency on reactor-addons and reactor-test...

the situation is not great though, but this is the first time it is reported. a workaround is simply to add reactor-extra as a dependency, but long term solution would probably be to have separate artifacts to mirror the reactor-core, reactor-adapter, reactor-extra and reactor-test artifacts 🤔

@simonbasle simonbasle added status/has-workaround This has a known workaround described status/need-decision This issue needs a decision and removed ❓need-triage This issue needs triage, hasn't been looked at by a team member yet labels Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/has-workaround This has a known workaround described status/need-decision This issue needs a decision
Projects
None yet
Development

No branches or pull requests

3 participants