Remove @Autowired from FeignClientFactoryBean

@Autowired causes NullPointerExceptions because of some unknown lifecycle issues. fixes gh-1366
parent ba3923d7
...@@ -51,9 +51,9 @@ import lombok.EqualsAndHashCode; ...@@ -51,9 +51,9 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
class FeignClientFactoryBean implements FactoryBean<Object>, InitializingBean, class FeignClientFactoryBean implements FactoryBean<Object>, InitializingBean,
ApplicationContextAware { ApplicationContextAware {
/***********************************
@Autowired * WARNING! Nothing in this class should be @Autowired. It causes NPEs because of some lifecycle race condition.
private Targeter targeter; ***********************************/
private Class<?> type; private Class<?> type;
...@@ -146,6 +146,7 @@ class FeignClientFactoryBean implements FactoryBean<Object>, InitializingBean, ...@@ -146,6 +146,7 @@ class FeignClientFactoryBean implements FactoryBean<Object>, InitializingBean,
Client client = getOptional(context, Client.class); Client client = getOptional(context, Client.class);
if (client != null) { if (client != null) {
builder.client(client); builder.client(client);
Targeter targeter = get(context, Targeter.class);
return targeter.target(this, builder, context, target); return targeter.target(this, builder, context, target);
} }
...@@ -183,6 +184,7 @@ class FeignClientFactoryBean implements FactoryBean<Object>, InitializingBean, ...@@ -183,6 +184,7 @@ class FeignClientFactoryBean implements FactoryBean<Object>, InitializingBean,
} }
builder.client(client); builder.client(client);
} }
Targeter targeter = get(context, Targeter.class);
return targeter.target(this, builder, context, new HardCodedTarget<>( return targeter.target(this, builder, context, new HardCodedTarget<>(
this.type, this.name, url)); this.type, this.name, url));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment