{"action":"created","issue":{"url":"https://api.github.com/repos/spring-cloud/spring-cloud-config/issues/1166","repository_url":"https://api.github.com/repos/spring-cloud/spring-cloud-config","labels_url":"https://api.github.com/repos/spring-cloud/spring-cloud-config/issues/1166/labels{/name}","comments_url":"https://api.github.com/repos/spring-cloud/spring-cloud-config/issues/1166/comments","events_url":"https://api.github.com/repos/spring-cloud/spring-cloud-config/issues/1166/events","html_url":"https://github.com/spring-cloud/spring-cloud-config/issues/1166","id":369420552,"node_id":"MDU6SXNzdWUzNjk0MjA1NTI=","number":1166,"title":"RabbitMQ CachingConnectionFactory with @RefreshScope Annotation to Report Error","user":{"login":"cambierr","id":10885859,"node_id":"MDQ6VXNlcjEwODg1ODU5","avatar_url":"https://avatars2.githubusercontent.com/u/10885859?v=4","gravatar_id":"","url":"https://api.github.com/users/cambierr","html_url":"https://github.com/cambierr","followers_url":"https://api.github.com/users/cambierr/followers","following_url":"https://api.github.com/users/cambierr/following{/other_user}","gists_url":"https://api.github.com/users/cambierr/gists{/gist_id}","starred_url":"https://api.github.com/users/cambierr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cambierr/subscriptions","organizations_url":"https://api.github.com/users/cambierr/orgs","repos_url":"https://api.github.com/users/cambierr/repos","events_url":"https://api.github.com/users/cambierr/events{/privacy}","received_events_url":"https://api.github.com/users/cambierr/received_events","type":"User","site_admin":false},"labels":[{"id":106767386,"node_id":"MDU6TGFiZWwxMDY3NjczODY=","url":"https://api.github.com/repos/spring-cloud/spring-cloud-config/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/spring-cloud/spring-cloud-config/milestones/56","html_url":"https://github.com/spring-cloud/spring-cloud-config/milestone/56","labels_url":"https://api.github.com/repos/spring-cloud/spring-cloud-config/milestones/56/labels","id":3757235,"node_id":"MDk6TWlsZXN0b25lMzc1NzIzNQ==","number":56,"title":"1.4.6.RELEASE","description":"","creator":{"login":"ryanjbaxter","id":524254,"node_id":"MDQ6VXNlcjUyNDI1NA==","avatar_url":"https://avatars1.githubusercontent.com/u/524254?v=4","gravatar_id":"","url":"https://api.github.com/users/ryanjbaxter","html_url":"https://github.com/ryanjbaxter","followers_url":"https://api.github.com/users/ryanjbaxter/followers","following_url":"https://api.github.com/users/ryanjbaxter/following{/other_user}","gists_url":"https://api.github.com/users/ryanjbaxter/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanjbaxter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanjbaxter/subscriptions","organizations_url":"https://api.github.com/users/ryanjbaxter/orgs","repos_url":"https://api.github.com/users/ryanjbaxter/repos","events_url":"https://api.github.com/users/ryanjbaxter/events{/privacy}","received_events_url":"https://api.github.com/users/ryanjbaxter/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":1,"state":"open","created_at":"2018-10-22T14:20:32Z","updated_at":"2018-10-26T00:36:42Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2018-10-12T06:47:57Z","updated_at":"2018-10-26T15:09:29Z","closed_at":null,"author_association":"NONE","body":"In my current setup, I have a configuration class exposing a `CachingConnectionFactory` bean like so:\r\n\r\n```java\r\n@Bean\r\n    @RefreshScope\r\n    public CachingConnectionFactory cachingConnectionFactory() throws Exception {\r\n        \r\n        RabbitConnectionFactoryBean factory = new RabbitConnectionFactoryBean();\r\n        factory.setPort(port);\r\n        factory.setUsername(username);\r\n        factory.setPassword(password);\r\n        factory.setVirtualHost(vhost);\r\n        factory.setRequestedHeartbeat((int) (heartbeatPeriod / 1000));\r\n        factory.setMetricsCollector(metricsCollector);\r\n        factory.afterPropertiesSet();\r\n\r\n        String localApplicationName = context.getId().split(\":\")[0];\r\n        AtomicInteger connectionCounter = new AtomicInteger();\r\n\r\n        CachingConnectionFactory connectionFactory = new CachingConnectionFactory(factory.getObject());\r\n        connectionFactory.setConnectionNameStrategy(connectionFactory1 -> localApplicationName + \"#\" + connectionCounter.incrementAndGet());\r\n\r\n        List<ServiceInstance> rabbitHosts = discoveryClient.getInstances(\"rabbitmq\");\r\n        StringJoiner sj = new StringJoiner(\",\");\r\n        if (rabbitHosts.size() > 0) {\r\n            LOGGER.info(\"Found \" + rabbitHosts.size() + \" instances of RabbitMQ, using them !\");\r\n            for (ServiceInstance rabbitmq : rabbitHosts) {\r\n                sj.add(rabbitmq.getHost() + \":5672\");\r\n            }\r\n        } else {\r\n            LOGGER.info(\"No instance of RabbitMQ, falling back to ${rabbitmq.hosts} !\");\r\n            for (String rabbitmq : hosts) {\r\n                if (!rabbitmq.isEmpty()) {\r\n                    sj.add(rabbitmq);\r\n                }\r\n            }\r\n        }\r\n\r\n        if (sj.length() > 0) {\r\n            connectionFactory.setAddresses(sj.toString());\r\n        }\r\n\r\n        return connectionFactory;\r\n    }\r\n```\r\n\r\nand this is fine for months. Bu I'm now looking at adding `@RefreshScope` to both my configuration class and the exposed `CachingConnectionFactory` bean, which creates this error:\r\n\r\n```text\r\n...\r\nCaused by: java.lang.NullPointerException: null\r\n\tat org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:585) ~[spring-rabbit-1.7.10.RELEASE.jar:na]\r\n\tat <internal>\r\n\tat <internal>\r\n\tat <internal>\r\n\tat <internal>\r\n\tat org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.19.RELEASE.jar:4.3.19.RELEASE]\r\n\tat org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]\r\n\tat <internal>\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]\r\n\tat java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]\r\n\tat org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]\r\n\t... 161 common frames omitted\r\n```\r\n\r\nThis seems to be thrown here:\r\n```java\r\n@Override\r\n\tpublic final Connection createConnection() throws AmqpException {\r\n\t\tAssert.state(!this.stopped, \"The ApplicationContext is closed and the ConnectionFactory can no longer create connections.\");\r\n\t\tsynchronized (this.connectionMonitor) {  // <---- connectionMonitor is null, as well as all other fields\r\n```\r\nbut, `connectionMonitor` is declared using: `private final Object connectionMonitor = new Object();`\r\n\r\nSo at this point, I'm not sure to know how to solve this.\r\n\r\nBase on **boot 1.5.16.RELEASE** and **cloud Edgware.SR3**"},"comment":{"url":"https://api.github.com/repos/spring-cloud/spring-cloud-config/issues/comments/433441055","html_url":"https://github.com/spring-cloud/spring-cloud-config/issues/1166#issuecomment-433441055","issue_url":"https://api.github.com/repos/spring-cloud/spring-cloud-config/issues/1166","id":433441055,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMzQ0MTA1NQ==","user":{"login":"ryanjbaxter","id":524254,"node_id":"MDQ6VXNlcjUyNDI1NA==","avatar_url":"https://avatars1.githubusercontent.com/u/524254?v=4","gravatar_id":"","url":"https://api.github.com/users/ryanjbaxter","html_url":"https://github.com/ryanjbaxter","followers_url":"https://api.github.com/users/ryanjbaxter/followers","following_url":"https://api.github.com/users/ryanjbaxter/following{/other_user}","gists_url":"https://api.github.com/users/ryanjbaxter/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanjbaxter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanjbaxter/subscriptions","organizations_url":"https://api.github.com/users/ryanjbaxter/orgs","repos_url":"https://api.github.com/users/ryanjbaxter/repos","events_url":"https://api.github.com/users/ryanjbaxter/events{/privacy}","received_events_url":"https://api.github.com/users/ryanjbaxter/received_events","type":"User","site_admin":false},"created_at":"2018-10-26T15:09:29Z","updated_at":"2018-10-26T15:09:29Z","author_association":"CONTRIBUTOR","body":"No looked at it a bit and it seems like it might have to do with the class being a proxy but I cant explain why.  I am going to bring this up at our team meeting next week"}}
{"actor":{"display_login":"ryanjbaxter"}}