question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to set contextProgagator from application.properties

See original GitHub issue

Resilience4j version: 1.3.1

Java version: openjdk 11.0.2 2019-01-15

I am trying to set up resilience4ji in a SpringBootApp. I am setting up ThreadpoolBulkhead in application.properties. As part of that I am also trying to set context propagators, however the application fails to start.

application.properties

... #Other properties of ThreadPoolBulkhead over-ridden
resilience4j.thread-pool-bulkhead.configs.default.keepAliveDuration=20ms
resilience4j.thread-pool-bulkhead.configs.default.contextPropagators=com.app.MdcContextPropagator

The MdcContextPropagator is used to pass the MDC context to between threads and is implemented as below

@Component
public class MdcContextPropagator implements ContextPropagator<Map<String, String>> {

    @Override
    public Supplier<Optional<Map<String, String>>> retrieve() {
        return () -> Optional.ofNullable(MDC.getCopyOfContextMap());
    }

    @Override
    public Consumer<Optional<Map<String, String>>> copy() {
        return (copyOfContextMap) -> copyOfContextMap.ifPresent(MDC::setContextMap);
    }

    @Override
    public Consumer<Optional<Map<String, String>>> clear() {
        return (contextMap) -> MDC.clear();
    }
}

Stacktrace for application startup failure

2020-04-19T17:55:25.220+0530 WARN   [main] x-b3-traceId= o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'threadPoolBulkHeadCustomizer': Invocation of init method failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'scopedTarget.threadPoolBulkheadRegistry' defined in class path resource [io/github/resilience4j/bulkhead/autoconfigure/RefreshScopedBulkheadAutoConfiguration.class]: Unsatisfied dependency expressed through method 'threadPoolBulkheadRegistry' parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'resilience4j.thread-pool-bulkhead-io.github.resilience4j.bulkhead.autoconfigure.ThreadPoolBulkheadProperties': Could not bind properties to 'ThreadPoolBulkheadProperties' : prefix=resilience4j.thread-pool-bulkhead, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'resilience4j.thread-pool-bulkhead.configs.default' to io.github.resilience4j.common.bulkhead.configuration.ThreadPoolBulkheadConfigurationProperties$InstanceProperties 
...
***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to bind properties under 'resilience4j.thread-pool-bulkhead.configs.default' to io.github.resilience4j.common.bulkhead.configuration.ThreadPoolBulkheadConfigurationProperties$InstanceProperties:

    Reason: No setter found for property: context-propagators

If I remove the contextPropagator part from my application.properties file I can start the application. However I would like to use the properties file to set contextPropagator, but not possible to do

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
RobWincommented, Apr 22, 2020

I quickly added the method

1reaction
RobWincommented, Apr 20, 2020

Yes, a PR is welcome. Please just deprecate the old method and add a correct one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resilience4j context propagator not able to propagte thread ...
I am trying to migrate my circuit breaker code from Hystrix to Resilience4j. The communication is between two applications out of ...
Read more >
OpenTelemetry Context Propagation | Lightstep blog
This is usually caused by failing to install instrumentation for your HTTP client or your HTTP server. The second issue is misconfigured  ......
Read more >
Spring Cloud Sleuth Features
1. Context Propagation. Traces connect from service to service using header propagation. The default format is B3. Similar to data formats, you can...
Read more >
Spring Security Context Propagation with @Async - Baeldung
So, as you can see, inside the executor thread, our call fails with a NPE, as expected – because the Principal isn't available...
Read more >
Propagators API - OpenTelemetry
Each concern creates a set of Propagators for every supported Propagator type. ... write context data to and from messages exchanged by the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found