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

$ expression in @Client not resolved in Kotlin project #1278

Closed
3 of 4 tasks
abelsromero opened this issue Feb 21, 2019 · 1 comment
Closed
3 of 4 tasks

$ expression in @Client not resolved in Kotlin project #1278

abelsromero opened this issue Feb 21, 2019 · 1 comment
Assignees
Labels
type: bug Something isn't working
Milestone

Comments

@abelsromero
Copy link

abelsromero commented Feb 21, 2019

It seems to be the same issue reported in #1144 and supposedly closed.

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Steps to Reproduce

  1. Create new app with mn create-app junit-issue-demo --lang=kotlin --features=junit
  2. Update dependency testCompile "org.junit.jupiter:junit-jupiter-api:5.1.0" to 5.3.0 or higher. Otherwise tests don't work
  3. Add configuration to application.yml as follows:
jbcn:
  clients:
    cfp:
      endpoint: https://domain/endpoint
  1. Create @singleton service
@Singleton
class CfpapiClient(
    @Client("\${jbcn.clients.cfp.endpoint}")
    @Inject
    val httpClient: RxHttpClient
) {

    @Value("\${jbcn.clients.cfp.endpoint}")
    lateinit var value:String

    companion object {
        @JvmStatic
        private val logger = LoggerFactory.getLogger(SpeakersController::class.java)
    }

    fun getAllSpeakers(): Flowable<MapSearchResult> {
        val req = HttpRequest.GET<Any>("speakers.json")
        return httpClient.retrieve(req, Argument.of(MapSearchResult::class.java))
    }
}

NOTE: MapSearchResult is a simple pojo

  1. Add @controller that calls getAllSpeakers()
  2. Start server
  3. Invoke controller method

Stacktrace

17:59:33.647 [main] INFO  io.micronaut.runtime.Micronaut - Startup completed in 1424ms. Server Running: http://localhost:8080
17:59:37.581 [nioEventLoopGroup-1-2] ERROR i.m.h.s.netty.RoutingInBoundHandler - Unexpected error occurred: No available services for ID: ${jbcn.clients.cfp.endpoint}
io.micronaut.discovery.exceptions.NoAvailableServiceException: No available services for ID: ${jbcn.clients.cfp.endpoint}
	at io.micronaut.http.client.loadbalance.AbstractRoundRobinLoadBalancer.getNextAvailable(AbstractRoundRobinLoadBalancer.java:51)
	at io.micronaut.core.async.publisher.Publishers$1.doOnNext(Publishers.java:143)
	at io.micronaut.core.async.subscriber.CompletionAwareSubscriber.onNext(CompletionAwareSubscriber.java:53)
	at io.reactivex.internal.util.HalfSerializer.onNext(HalfSerializer.java:45)
	at io.reactivex.internal.subscribers.StrictSubscriber.onNext(StrictSubscriber.java:97)
	at io.reactivex.internal.subscriptions.ScalarSubscription.request(ScalarSubscription.java:55)
	at io.reactivex.internal.subscriptions.SubscriptionHelper.deferredSetOnce(SubscriptionHelper.java:210)
	at io.reactivex.internal.subscribers.StrictSubscriber.onSubscribe(StrictSubscriber.java:87)
	at io.reactivex.internal.operators.flowable.FlowableJust.subscribeActual(FlowableJust.java:34)
	at io.reactivex.Flowable.subscribe(Flowable.java:14479)
	at io.reactivex.Flowable.subscribe(Flowable.java:14429)
	at io.micronaut.core.async.publisher.Publishers.lambda$map$2(Publishers.java:134)
	at io.micronaut.core.async.publisher.Publishers.lambda$map$2(Publishers.java:134)
	at io.reactivex.internal.operators.flowable.FlowableFromPublisher.subscribeActual(FlowableFromPublisher.java:29)
	at io.reactivex.Flowable.subscribe(Flowable.java:14479)
	at io.reactivex.internal.operators.flowable.FlowableSwitchMap.subscribeActual(FlowableSwitchMap.java:49)
	at io.reactivex.Flowable.subscribe(Flowable.java:14479)
	at io.reactivex.Flowable.subscribe(Flowable.java:14429)
	at io.micronaut.core.async.publisher.Publishers.lambda$map$2(Publishers.java:134)
	at io.reactivex.internal.operators.flowable.FlowableFromPublisher.subscribeActual(FlowableFromPublisher.java:29)
	at io.reactivex.Flowable.subscribe(Flowable.java:14479)
	at io.reactivex.internal.operators.flowable.FlowableElementAtMaybe.subscribeActual(FlowableElementAtMaybe.java:36)
	at io.reactivex.Maybe.subscribe(Maybe.java:4154)
	at io.reactivex.internal.operators.maybe.MaybeMap.subscribeActual(MaybeMap.java:40)
	at io.reactivex.Maybe.subscribe(Maybe.java:4154)
	at io.reactivex.internal.operators.maybe.MaybeToFlowable.subscribeActual(MaybeToFlowable.java:45)
	at io.reactivex.Flowable.subscribe(Flowable.java:14479)
	at io.reactivex.internal.operators.flowable.FlowableMap.subscribeActual(FlowableMap.java:37)
	at io.reactivex.Flowable.subscribe(Flowable.java:14479)
	at io.reactivex.internal.operators.flowable.FlowableSwitchIfEmpty.subscribeActual(FlowableSwitchIfEmpty.java:32)
	at io.reactivex.Flowable.subscribe(Flowable.java:14479)
	at io.reactivex.Flowable.subscribe(Flowable.java:14426)
	at io.reactivex.internal.operators.flowable.FlowableSwitchMap$SwitchMapSubscriber.onNext(FlowableSwitchMap.java:129)
	at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.onNext(FlowableSubscribeOn.java:97)
	at io.micronaut.http.context.ServerRequestTracingPublisher$1.lambda$onNext$1(ServerRequestTracingPublisher.java:61)
	at io.micronaut.http.context.ServerRequestContext.with(ServerRequestContext.java:53)
	at io.micronaut.http.context.ServerRequestTracingPublisher$1.onNext(ServerRequestTracingPublisher.java:61)
	at io.micronaut.http.context.ServerRequestTracingPublisher$1.onNext(ServerRequestTracingPublisher.java:53)
	at io.reactivex.internal.util.HalfSerializer.onNext(HalfSerializer.java:45)
	at io.reactivex.internal.subscribers.StrictSubscriber.onNext(StrictSubscriber.java:97)
	at io.reactivex.internal.operators.flowable.FlowableSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FlowableSwitchIfEmpty.java:59)
	at io.reactivex.internal.operators.flowable.FlowableMap$MapSubscriber.onNext(FlowableMap.java:68)
	at io.reactivex.internal.operators.flowable.FlowableCreate$NoOverflowBaseAsyncEmitter.onNext(FlowableCreate.java:403)
	at io.micronaut.http.server.netty.RoutingInBoundHandler.lambda$buildResultEmitter$16(RoutingInBoundHandler.java:1310)
	at io.reactivex.internal.operators.flowable.FlowableCreate.subscribeActual(FlowableCreate.java:71)
	at io.reactivex.Flowable.subscribe(Flowable.java:14479)
	at io.reactivex.internal.operators.flowable.FlowableMap.subscribeActual(FlowableMap.java:37)
	at io.reactivex.Flowable.subscribe(Flowable.java:14479)
	at io.reactivex.internal.operators.flowable.FlowableSwitchIfEmpty.subscribeActual(FlowableSwitchIfEmpty.java:32)
	at io.reactivex.Flowable.subscribe(Flowable.java:14479)
	at io.reactivex.Flowable.subscribe(Flowable.java:14429)
	at io.micronaut.http.context.ServerRequestTracingPublisher.lambda$subscribe$0(ServerRequestTracingPublisher.java:53)
	at io.micronaut.http.context.ServerRequestContext.with(ServerRequestContext.java:53)
	at io.micronaut.http.context.ServerRequestTracingPublisher.subscribe(ServerRequestTracingPublisher.java:53)
	at io.reactivex.internal.operators.flowable.FlowableFromPublisher.subscribeActual(FlowableFromPublisher.java:29)
	at io.reactivex.Flowable.subscribe(Flowable.java:14479)
	at io.reactivex.Flowable.subscribe(Flowable.java:14426)
	at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run(FlowableSubscribeOn.java:82)
	at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker$BooleanRunnable.run(ExecutorScheduler.java:260)
	at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker.run(ExecutorScheduler.java:225)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:462)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)

Expected Behaviour

The configuration property in @Client should be resolved and remote invocation of httpClient should work.

Actual Behaviour

The property does not seem to be resolved. It is correctly resolver however in the other bean property lateinit var value:String.
Note that everything works fine when setting the url directly in @Client

Environment Information

  • Operating System:
    Linux 4.19.23-1-MANJARO Some documentation fixes #1 SMP PREEMPT Fri Feb 15 21:27:33 UTC 2019 x86_64 GNU/Linux
  • Micronaut Version:
    Micronaut Version: 1.0.4
  • JDK Version:
    JVM Version: Oracle 1.8.0_201

Example Application

@jameskleeh
Copy link
Contributor

@abelsromero This is not the same issue because you're doing constructor injection and the issue you linked was using field injection

@jameskleeh jameskleeh self-assigned this Feb 22, 2019
@jameskleeh jameskleeh added lang: kotlin Issues or features specific to Kotlin status: awaiting validation Waiting to be validated as a real issue labels Feb 22, 2019
@jameskleeh jameskleeh added type: bug Something isn't working and removed lang: kotlin Issues or features specific to Kotlin status: awaiting validation Waiting to be validated as a real issue labels Feb 25, 2019
@jameskleeh jameskleeh added this to the 1.1.0 milestone Feb 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants