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

25th
Jan 2017
Bryan Perino
@bryantp
Jan 25 2017 16:04
@here How would I invalidate my session in a Spring Cloud app?
@dsyer So, make the ResourceServerProperties be a singleton again, but find a way to modify the request on a per request basis?
Dave Syer
@dsyer
Jan 25 2017 16:13
That's what I suggested (can we move this conversation to #spring-security?)
Invalidating sessions is also not a Cloud feature
Bryan Perino
@bryantp
Jan 25 2017 16:59
Sure thing. Sorry to jump around a bit, but in the end I have to use AuthorizationCodeResourceDetails and not ResourceServerProperties, for myproblem
I am able to generate the AuthorizationCodeResourceDetails by following your suggestion of overriding the bean in a bpp.
However, I am getting a StackOverflowError when a a request comes in.
Dave Syer
@dsyer
Jan 25 2017 17:00
Cool!
Bryan Perino
@bryantp
Jan 25 2017 17:01
 @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if(bean instanceof AuthorizationCodeResourceDetails && !beanName.equals("customerAuthCodeDetails")){
            return coerce();
        }
        return bean;
    }

    private Object coerce(){
        return context.getBean("customerAuthCodeDetails");
    }

    @Bean(name = "customerAuthCodeDetails")
    @Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
    public AuthorizationCodeResourceDetails customerAuthCodeDetails(){
        AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails();
        final String currentAccessTokenUri = "http://coke.uaa.mysite.io:8080/uaa/oauth/token";
        final String userAuthUrl = "http://coke.uaa.mysite.io:8080/uaa/oauth/authorize";
        details.setAccessTokenUri(currentAccessTokenUri);
        details.setUserAuthorizationUri(userAuthUrl);
        return details;
    }
It's progress though
java.lang.StackOverflowError: null
    at java.lang.ThreadLocal.get(ThreadLocal.java:161) ~[na:1.8.0_77]
    at org.springframework.beans.factory.support.AbstractBeanFactory.isPrototypeCurrentlyInCreation(AbstractBeanFactory.java:989) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:260) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35) ~[spring-aop-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:187) ~[spring-aop-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at com.sun.proxy.$Proxy93.isClientOnly(Unknown Source) ~[na:na]
    at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source) ~[na:na]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_77]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_77]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) ~[spring-aop-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) ~[spring-aop-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) ~[spring-aop-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208) ~[spring-aop-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at com.sun.proxy.$Proxy93.isClientOnly(Unknown Source) ~[na:na]
    at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source) ~[na:na]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_77]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_77]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) ~[spring-aop-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntro
Bryan Perino
@bryantp
Jan 25 2017 17:27
I'm not sure why that would happen?
Dave Syer
@dsyer
Jan 25 2017 17:38
The proxy has a reference to itself as its own target
That's sad
I'm sure there must be a way to make it work
Bryan Perino
@bryantp
Jan 25 2017 17:43
Changing the ProxyMode just results in a different error, but on startup
Dave Syer
@dsyer
Jan 25 2017 17:47
I can reproduce it easily.
Let me think for a minute
Dave Syer
@dsyer
Jan 25 2017 17:57
In your post processor you need to exclude proxy targets
It's sufficient in this case to add && !beanName.startsWith("scopedTarget") to the if condition
Bryan Perino
@bryantp
Jan 25 2017 18:28
ok. I remember hitting a StackOverflow error before due to me not filtering at all.
I'll give that a try!
Mike Liu
@mikexliu
Jan 25 2017 21:19

hi! i have 2 eureka servers and and i keep getting:

c.n.e.cluster.ReplicationTaskProcessor   : Batch update failure with HTTP status code 401; discarding 1 replication tasks
c.n.eureka.util.batcher.TaskExecutors    : Discarding 1 tasks of TaskBatchingWorker-target_abc-3 due to permanent error

I'm not sure how i can provide the basic auth information.

I injected

@Bean
public DiscoveryClient.DiscoveryClientOptionalArgs discoveryClientOptionalArgsProvider() {
  // ...
}

and that seemed to work for the client, but not sure how the server side can also use the basic auth to replicate itself. didn't find anything in the docs about this case either

@dsyer
Regarding my previous question: is there a way to link eureka-client with hystrix-dashboard?, I basically added a HystrixCommand wrapper around the ClientRequest.execute() call to get what i wanted (which is having the client's failures show up in hystrix streams)
Josh Fix
@joshfix
Jan 25 2017 22:07
I'm seeing some odd behavior with consul -- I created a class that uses @RefreshScope to accept dynamic updates from config changes in consul, and a method annotated with @EventListener that listens for EnvironmentChangeEvents, expecting that when the event fires, I will see the updated value of my variable. The very first time my project starts, the variable i'm trying to change is set to "NONE". If I change the value in consul, my event listener fires, but the variable still has the value "NONE". All subsequent updates work fine -- that is, when the event fires, I see the value I just changed it to.
I added a GetMapping to return the value of the variable after the first event, thinking maybe something weird was going on. Sure enough, the variable does update, but just after the event has fired.
Here is my class:

`@Slf4j
@AllArgsConstructor
@RefreshScope
@Component
@ConfigurationProperties(prefix="resource.store.modification")
@RestController
public class ResourceEventListener {

@Getter
@Setter
private String event;

@GetMapping(value = "/getEvent")
public String getEventValue() {
    return event;
}

@EventListener
public void onApplicationEvent(EnvironmentChangeEvent ece) {
    if (null == ece.getKeys() || ece.getKeys().isEmpty() || !ece.getKeys().contains("resource.store.modification.event")) {
        return;
    }
    log.info("APP EVENT: " + getEvent());
}

}`

i could potentially build a simple project to repeat it, although it would have the consul dependency
Dave Syer
@dsyer
Jan 25 2017 22:22
@mikexliu you can add basic auth to eureka client via the URL (as long as it is the latest version - there was a glitch with some early Brixton releases I think)
The server is a c lient, so whatever works for the server works there as well
Bryan Perino
@bryantp
Jan 25 2017 23:29
For FeignClient, whenever I try to make a call I keep getting a 401. Is there some setup I need to do?
Rob Moore
@robmoore
Jan 25 2017 23:51
I'm trying to use Joda LocalDates in an object that is serialized and am getting an error that I believe is perhaps related to Kyro not having serializers for Joda types. Just curious if anyone has done something like this before.