These are chat archives for spring-cloud/spring-cloud

6th
Oct 2016
Stian Lågstad
@stianlagstad
Oct 06 2016 08:39
Hi. Is it possible to disable a RequestInterceptor if I'm using @Cacheable? I have an interceptor that logs "Calling service XYZ with ...", and I don't want that when the value is retrieved from cache.
Stian Lågstad
@stianlagstad
Oct 06 2016 13:30
Anyone?
Ryan Baxter
@ryanjbaxter
Oct 06 2016 14:23
@stianlagstad that seems like more of Spring Boot question
unless u are talking about a RequestInterceptor in Spring Cloud
Stian Lågstad
@stianlagstad
Oct 06 2016 14:32
I believe I'm talking about the RequestInterceptor in spring cloud
Stian Lågstad
@stianlagstad
Oct 06 2016 14:47
That one, yes
Spencer Gibb
@spencergibb
Oct 06 2016 14:48
there’s no link between @Cacheable and a RequestInterceptor
Stian Lågstad
@stianlagstad
Oct 06 2016 14:48
So the answer to the question "Is it possible to only trigger the interceptor if there's actually an external call being made?" would be.. no?
Spencer Gibb
@spencergibb
Oct 06 2016 14:50
You can do anything you want in an interceptor, but interceptors don’t run conditionally.
Stian Lågstad
@stianlagstad
Oct 06 2016 14:50
Alright, thanks!
Dieter Hubau
@Turbots
Oct 06 2016 15:33
problem: I’m configuring a @FeignClientinterface like this:
@FeignClient(name = "budget-service", url = "${budget.service.url}")
public interface PreventieEenhedenResource extends BudgetVerbruikService {

    @RequestMapping(value = "/budget/verbruik", method = RequestMethod.GET)
    VerbruikPreventieEenheden getPreventieEenheden(@RequestParam("parId") String parId, @RequestParam("year") String year);
}
and I have a @Component class implementing this interface as a fallback
but when I start up my application (or run a unit test) I get the following error:
Caused by: java.lang.NullPointerException
    at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:184)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
It appears the Targeter instance in that code is empty, but it should get autowired
Spencer Gibb
@spencergibb
Oct 06 2016 15:35
something is causing your feign client to be initialized too early.
Dieter Hubau
@Turbots
Oct 06 2016 15:37
oh..
I’m autowiring my @Componentin a regular @Serviceas in many examples
Spencer Gibb
@spencergibb
Oct 06 2016 15:37
What version are you using?
Dieter Hubau
@Turbots
Oct 06 2016 15:38
spring-boot-1.4.1.RELEASE and spring-cloud-Camden.RELEASE
(latest I guess)
Spencer Gibb
@spencergibb
Oct 06 2016 15:38
yeah, just noticed something that could cause this
Dieter Hubau
@Turbots
Oct 06 2016 15:39
I dont have any @Configuration classes except for my main @SpringBootApplication class
Spencer Gibb
@spencergibb
Oct 06 2016 15:39
yeah
Dieter Hubau
@Turbots
Oct 06 2016 15:39
should I create a separate @Configuration class? That one would load later right?
Spencer Gibb
@spencergibb
Oct 06 2016 15:40
If it helps, I’m about to fix the cause
Dieter Hubau
@Turbots
Oct 06 2016 15:41
that would be very helpful for the future, but can you steer me into a temporary workaround?
make my own @HystrixTargeter maybe?
Spencer Gibb
@spencergibb
Oct 06 2016 15:41
Not sure
Dieter Hubau
@Turbots
Oct 06 2016 15:41
let me try
hmmm, if I try to add the hystrixtargeter bean myself, I cannot import it, since its not in my project, its in the spring-cloud-netflix-core dependency
but that one is definitely on my classpath… wtf :)
nvm, its a package private class
so I cannot create the bean myself :)
Spencer Gibb
@spencergibb
Oct 06 2016 15:46
yeah, you shouldn’t have to
@Turbots how simple is your app? simple enough to share?
Dieter Hubau
@Turbots
Oct 06 2016 15:51
ill make one in a minute, trying stuff out
Spencer Gibb
@spencergibb
Oct 06 2016 15:52
I’d love a sample so we can prevent this in the future.
Dieter Hubau
@Turbots
Oct 06 2016 15:58
yes @spencergibb that indeed fixes the problem! thanks!
i’ll make a small sample in a bit
Dieter Hubau
@Turbots
Oct 06 2016 16:17
the only thing that is failing now are my @WebMvcTests since they now also startup the Feign configuration :) he cant find the fallbacks, but I can add them np :)
Dieter Hubau
@Turbots
Oct 06 2016 16:46
if I try to reproduce it in a smaller project (my project was already small, ive started working on it on Monday) then I cant :(
Spencer Gibb
@spencergibb
Oct 06 2016 16:47
:-) This is my problem.
Dieter Hubau
@Turbots
Oct 06 2016 16:50
true, but its bugging me that I cant find out what is triggering this weird lifecycle condition
Dieter Hubau
@Turbots
Oct 06 2016 16:56
found it @spencergibb
the moment I add the spring-boot-devtools dependency, it gives me the error
Spencer Gibb
@spencergibb
Oct 06 2016 16:58
ok
here’s a sample for you :)
Spencer Gibb
@spencergibb
Oct 06 2016 17:21
@Turbots thanks!
Matt Benson
@mbenson
Oct 06 2016 18:50
hmm, just tried to upgrade to Camden and I must say hiding FeignClientsRegistrar after having already released it publicly isn't the friendliest backward compatibility policy I've encountered
Spencer Gibb
@spencergibb
Oct 06 2016 18:53
what are you doing with it?
Matt Benson
@mbenson
Oct 06 2016 18:54
I was using it in the bootstrap context to pre-inspect the Feign proxies, thus enabling me to create a PropertySource from a -Locator that could detect version information per interface
Spencer Gibb
@spencergibb
Oct 06 2016 18:59
Would you open an issue and describe what you are doing? There will be an SR1 shortly
Matt Benson
@mbenson
Oct 06 2016 19:00
okay, thanks!
Spencer Gibb
@spencergibb
Oct 06 2016 19:00
My thinking was it’s an implementation detail that leaked
Matt Benson
@mbenson
Oct 06 2016 19:07
I imagined so. Can you think of a way to trigger it in the bootstrap context without requiring access to the type?
Spencer Gibb
@spencergibb
Oct 06 2016 19:08
Not that I know of. Describe in a little more detail in the issue what you are doing.
Matt Benson
@mbenson
Oct 06 2016 19:08
k
Spencer Gibb
@spencergibb
Oct 06 2016 19:09
Likely I’ll just make it public again and see what we can do in the next release to remove that again, but provide you with what you need.
Matt Benson
@mbenson
Oct 06 2016 19:48
just opened #1383
Spencer Gibb
@spencergibb
Oct 06 2016 20:23
thx
Matt Benson
@mbenson
Oct 06 2016 21:04
thank you!