Giter Site home page Giter Site logo

spring-cloud / spring-cloud-consul Goto Github PK

View Code? Open in Web Editor NEW
800.0 85.0 542.0 74.36 MB

Spring Cloud Consul

Home Page: http://cloud.spring.io/spring-cloud-consul/

License: Apache License 2.0

CSS 5.46% HTML 4.56% Java 88.97% Shell 0.09% Batchfile 0.93%
spring-boot spring java consul service-discovery configuration microservices cloud-native spring-cloud spring-cloud-core

spring-cloud-consul's Introduction

Actions Status
Codecov

Quick Start

Consul overview

Features of Consul

  • Distributed configuration

  • Service registration and discovery

  • Distributed events

  • Distributed locking and sessions

  • Supports multiple data centers

  • Built in, user-friendly user interface

See the intro for more information.

Spring Cloud Consul Features

  • Spring Cloud DiscoveryClient implementation

    • supports Spring Cloud Gateway

    • supports Spring Cloud LoadBalancer

  • Consul based PropertySource loaded during the 'bootstrap' phase.

  • Spring Cloud Bus implementation based on Consul events

Running the sample

  1. Run docker-compose up

  2. Verify consul is running by visiting http://localhost:8500

  3. Run mvn package this will bring in the required spring cloud maven repositories and build

  4. Run java -jar spring-cloud-consul-sample/target/spring-cloud-consul-sample-${VERSION}.jar

  5. visit http://localhost:8080, verify that {"serviceId":"<yourhost>:8080","host":"<yourhost>","port":8080} results

  6. run java -jar spring-cloud-consul-sample/target/spring-cloud-consul-sample-${VERSION}.jar --server.port=8081

  7. visit http://localhost:8080 again, verify that {"serviceId":"<yourhost>:8081","host":"<yourhost>","port":8081} eventually shows up in the results in a round robbin fashion (may take a minute or so).

Building

Building

Contributing

Contributing

spring-cloud-consul's People

Contributors

aatarasoff avatar dependabot-preview[bot] avatar devpreview avatar fkalisa avatar jkschneider avatar jmirc avatar lomeshpatel avatar lowzj avatar making avatar marcingrzejszczak avatar mattreyuk avatar mbenson avatar obfischer avatar olgamaciaszek avatar onobc avatar pjhampton avatar preetapan avatar pwielgolaski avatar robertmcnees avatar ryanjbaxter avatar sakanaou avatar spencergibb avatar spojowa avatar spring-builds avatar spring-operator avatar stewartie4 avatar tysewyn avatar varnson avatar venilnoronha avatar zanella avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spring-cloud-consul's Issues

Https support for health checks

It appears there are a couple options for health check support. A full health check URL and a URL auto generated based on environment settings.

Is there a way to have the health check URL use https without having to set the full url in configuration?

I've gleamed from the class below of the two options, but didn't know if there were others?

ConsulLifecycle.java::74 :

if (properties.getHealthCheckUrl() != null) {
  check.setHttp(properties.getHealthCheckUrl());
} else {
  check.setHttp(String.format("http://%s:%s%s", properties.getHostname(),
    service.getPort(), properties.getHealthCheckPath()));
}

Currently we have an application that is all https, but since the auto generated URL is http, the health check fails. Didn't know if I was missing something.

So I found another solution, not sure it would be optimal, but maybe it's the intended way of using healthCheckUrl. Just use Spring's filtering to get HOSTNAME and server.port at application startup.
(This dawned on me while writing up this issue)

spring:
  application:
    name: app_name
  cloud:
    config:
      uri: https://config.url:port
    consul:
      discovery:
        healthCheckUrl: https://${HOSTNAME}:${server.port}/health

Thanks!

[Question] Optional Service Discovery

Is there a way to enable service discovery optionally?

For example if we have some property like discovery.enabled = false, annotation processor skip service registration phase.

no ILoadBalancer / Consul

Running the example as given, the localhost:8080 says Error: No ILoadBalancer instance!

So we have seen that:

  • the push in Consul (registration) works
  • the discovery works
  • the load balancer does not work! There is no Consul specific Balancer implementation, and even though there is a ConsulServerList implementation, it is not wired, and attempting to wire it proves a little cumbersome, I wonder if you actually have it working, because me and my colleague could not,,

It seems unfinalized code or configuration, also felt when seeing a commented piece of code with ConsulLoadBalancer, which is a class that no longer exists!

Support consul ACL tokens

It would be helpful to support ACL tokens for consul calls, for the use case where ACLs have been established in Consul and are required for kv store access and/or service registration.

If ACLs are in place, there are two ways to provide the token to consul (per consul.io) - either at the agent level (with the acl_token config parameter), or on a call specific basis. In some use cases, multiple applications/services will share an agent and may have different acl tokens defined. In these cases, setting the acl token at the agent level is not sufficient. By defining the token in a bootstrap.yml file, spring cloud consul could then provide the token for each call.

The Ecwid/consul-api supports providing a token in the KeyValueClient, but currently does not have the same support in the AgentClient. I'll open up an issue with consul-api to support tokens in the AgentClient, and I think that can be resolved by following the same pattern that exists in the KeyValueClient.

Shutdown endpoint does not deregister management service

Now that #67 is closed, I've noticed that the management service is not deregistered with consul when calling the spring boot shutdown endpoint. Since the management service is not registered with an http check (or ttl), I believe the service will persist in consul indefinitely, or until a deregister consul api call is made.

Support watching keys and services directory

With Consul and other solutions like etcd, it is possible to watch for changes within services and keys directories. The current Spring Cloud API does not support this kind of functionality. Are there any plans to support this?

"Watches are a way of specifying a view of data (e.g. list of nodes, KV pairs, health checks) which is monitored for updates. "

See also: http://www.consul.io/docs/agent/watches.html

properties in application.yml are not loaded

I have been unable to get spring-cloud-consul to recognize any consul related properties in my application.yml file. I started with the following:

spring:
  cloud:
    consul:
      config:
        enabled: false

This is to disable consul configuration in my CI profile. This doesn't seem to work, as the application tries and fails to load KV data from a running consul instance. I've experimented with other properties (e.g. spring.cloud.consul.port), but no matter what I specify, the values are not being used by spring-cloud-consul.

I've also tried specifying properties in a bootstrap.yml file, but without any success.

Is this a bug, or am I configuring spring-cloud-consul in the wrong place?

Consul Service Discovery - unable to configure consul host/port

I'm using Spring Boot Web Starter 1.2.4.RELEASE/1.3.0.M1 with Consul 1.0.0.M1 (with consul config). I am able to configure consul host/port in registry using the below configuration in bootstrap.yml

cloud:
    consul:
      config:
        host: 127.0.0.1
        port: 8500

However, when I'm trying to write a client and change consul host port using the same above configurations in bootstrap.yml it doesn't seem to be picking it up. It still looks for consul at localhost:8500

Incorrect port registered when using management.port

In some instances it makes sense to run the spring boot management server on a different port from the primary application server. This can be accomplished by setting 'management.port'.
Documented in 41.3 here: http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-monitoring.html

When management.port is set, spring-cloud-consul registers two NewService's with consul, one for the primary application and one for the management. It is helpful to have both services registered in consul separately. However, both services are registered with a port equal to the management.port, making the application service entry in the consul catalog incorrect.

why nodeId as hostname?

i tried to setup a cluster with several docker-container and the nodeId inside these docker-containers is the containerId which is not resolvable as hostname (at least outside of a container).

i am just wondering if somewhere is stated, that the nodeId must be a (resolvable) hostname. as far as i see it (--node parameter doc), it is hostname by default but does not have to be, so it could be an arbitrary id...

wouldnt it be better to use the address in super-call in org.springframework.cloud.consul.discovery.ConsulServer.ConsulServer(final CatalogService service)? or am i missing something?

Consul with Turbine

Unable to use Turbine with Consul - it starts to look for Eureka instead and complains about finding 2 discovery beans?

Looks like Turbine starter is pulling in eureka client?

NOTE: exclude module: 'eureka-client' didn't help either

Non-resolvable parent POM

When trying to build this project from a clone I got the error "Non-resolvable parent POM: Could not find artifact org.springframework.cloud:spring-cloud-build:pom:1.0.0.BUILD-SNAPSHOT".

I Googled and found the comment on issue #13 of spring-cloud/spring-cloud-config about using mvn --settings .settings.xml compile to fix this.

I can create a pull request for the readme to add this between points 3 & 4 if that works for you.

ConsulProperties is not populated correctly

Using the latest code from master (revision dc3a367), I tried to run the sample application following the instructions and with various settings for where Consul was installed

The problem I noticed is that Spring Cloud Consul only worked when Consul was accessible via http://localhost:8500.

What I noticed while debugging, was that ConsulProperties was being instantiated too early and there for totally ignored the properties set in application.yml (resulting in the use of default values).

You can verify this behaviour by running the sample application with the following modifications:

Add the following to application.yml

spring:
  cloud:
    consul:
      host: someTest
      port: 9999

Change the main method in SampleApplication.java to:

public static void main(String[] args) {
        SpringApplication app = new SpringApplication(SampleApplication.class);
        app.addListeners(new ApplicationListener<ContextRefreshedEvent>() {
            @Override
            public void onApplicationEvent(ContextRefreshedEvent event) {
                final ConsulProperties consulProperties = event.getApplicationContext().getBean(ConsulProperties.class);
                log.info("ConsulProperties is {}", consulProperties);
                Assert.isTrue(consulProperties.getHost().equals("localhost"));
                Assert.isTrue(consulProperties.getPort() == 8500);
            }
        });
        app.run(args);
}

Throw an exception when sub folders are creating under the context

I am using the sample project and if I create the following structure the following exception is thrown

2015-06-18 16:55:33.119  INFO 26148 --- [           main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/lib/ant-javafx.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/lib/dt.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/lib/javafx-mx.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/lib/jconsole.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/lib/sa-jdi.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/lib/tools.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/charsets.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/deploy.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/javaws.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/jce.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/jfr.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/jfxswt.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/jsse.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/management-agent.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/plugin.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/resources.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/rt.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/ext/cldrdata.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/ext/dnsns.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/ext/jfxrt.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/ext/localedata.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/ext/nashorn.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/ext/sunec.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar, file:/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/ext/zipfs.jar, file:/Users/jmirc/dev/3-others/consul/target/classes/, file:/Users/jmirc/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.2.3.RELEASE/spring-boot-starter-web-1.2.3.RELEASE.jar, file:/Users/jmirc/.m2/repository/org/springframework/boot/spring-boot-starter/1.2.3.RELEASE/spring-boot-starter-1.2.3.RELEASE.jar, file:/Users/jmirc/.m2/repository/org/springframework/boot/spring-boot/1.2.3.RELEASE/spring-boot-1.2.3.RELEASE.jar, file:/Users/jmirc/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.2.3.RELEASE/spring-boot-autoconfigure-1.2.3.RELEASE.jar, file:/Users/jmirc/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.2.3.RELEASE/spring-boot-starter-logging-1.2.3.RELEASE.jar, file:/Users/jmirc/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.11/jcl-over-slf4j-1.7.11.jar, file:/Users/jmirc/.m2/repository/org/slf4j/jul-to-slf4j/1.7.11/jul-to-slf4j-1.7.11.jar, file:/Users/jmirc/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.11/log4j-over-slf4j-1.7.11.jar, file:/Users/jmirc/.m2/repository/ch/qos/logback/logback-classic/1.1.3/logback-classic-1.1.3.jar, file:/Users/jmirc/.m2/repository/ch/qos/logback/logback-core/1.1.3/logback-core-1.1.3.jar, file:/Users/jmirc/.m2/repository/org/yaml/snakeyaml/1.14/snakeyaml-1.14.jar, file:/Users/jmirc/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.2.3.RELEASE/spring-boot-starter-tomcat-1.2.3.RELEASE.jar, file:/Users/jmirc/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.0.20/tomcat-embed-core-8.0.20.jar, file:/Users/jmirc/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.0.20/tomcat-embed-el-8.0.20.jar, file:/Users/jmirc/.m2/repository/org/apache/tomcat/embed/tomcat-embed-logging-juli/8.0.20/tomcat-embed-logging-juli-8.0.20.jar, file:/Users/jmirc/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.0.20/tomcat-embed-websocket-8.0.20.jar, file:/Users/jmirc/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.4.5/jackson-databind-2.4.5.jar, file:/Users/jmirc/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.4.5/jackson-annotations-2.4.5.jar, file:/Users/jmirc/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.4.5/jackson-core-2.4.5.jar, file:/Users/jmirc/.m2/repository/org/hibernate/hibernate-validator/5.1.3.Final/hibernate-validator-5.1.3.Final.jar, file:/Users/jmirc/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar, file:/Users/jmirc/.m2/repository/org/jboss/logging/jboss-logging/3.1.3.GA/jboss-logging-3.1.3.GA.jar, file:/Users/jmirc/.m2/repository/com/fasterxml/classmate/1.0.0/classmate-1.0.0.jar, file:/Users/jmirc/.m2/repository/org/springframework/spring-core/4.1.6.RELEASE/spring-core-4.1.6.RELEASE.jar, file:/Users/jmirc/.m2/repository/org/springframework/spring-web/4.1.6.RELEASE/spring-web-4.1.6.RELEASE.jar, file:/Users/jmirc/.m2/repository/org/springframework/spring-aop/4.1.6.RELEASE/spring-aop-4.1.6.RELEASE.jar, file:/Users/jmirc/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar, file:/Users/jmirc/.m2/repository/org/springframework/spring-beans/4.1.6.RELEASE/spring-beans-4.1.6.RELEASE.jar, file:/Users/jmirc/.m2/repository/org/springframework/spring-context/4.1.6.RELEASE/spring-context-4.1.6.RELEASE.jar, file:/Users/jmirc/.m2/repository/org/springframework/spring-webmvc/4.1.6.RELEASE/spring-webmvc-4.1.6.RELEASE.jar, file:/Users/jmirc/.m2/repository/org/springframework/spring-expression/4.1.6.RELEASE/spring-expression-4.1.6.RELEASE.jar, file:/Users/jmirc/.m2/repository/org/springframework/boot/spring-boot-starter-actuator/1.2.3.RELEASE/spring-boot-starter-actuator-1.2.3.RELEASE.jar, file:/Users/jmirc/.m2/repository/org/springframework/boot/spring-boot-actuator/1.2.3.RELEASE/spring-boot-actuator-1.2.3.RELEASE.jar, file:/Users/jmirc/.m2/repository/com/ecwid/consul/consul-api/1.1.2/consul-api-1.1.2.jar, file:/Users/jmirc/.m2/repository/org/apache/httpcomponents/httpclient/4.3.6/httpclient-4.3.6.jar, file:/Users/jmirc/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar, file:/Users/jmirc/.m2/repository/commons-logging/commons-logging/1.1/commons-logging-1.1.jar, file:/Users/jmirc/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar, file:/Users/jmirc/.m2/repository/logkit/logkit/1.0.1/logkit-1.0.1.jar, file:/Users/jmirc/.m2/repository/avalon-framework/avalon-framework/4.1.3/avalon-framework-4.1.3.jar, file:/Users/jmirc/.m2/repository/javax/servlet/servlet-api/2.3/servlet-api-2.3.jar, file:/Users/jmirc/.m2/repository/com/google/code/gson/gson/2.3.1/gson-2.3.1.jar, file:/Users/jmirc/.m2/repository/org/springframework/cloud/spring-cloud-commons/1.0.2.BUILD-SNAPSHOT/spring-cloud-commons-1.0.2.BUILD-20150617.043931-18.jar, file:/Users/jmirc/.m2/repository/org/springframework/security/spring-security-crypto/3.2.7.RELEASE/spring-security-crypto-3.2.7.RELEASE.jar, file:/Users/jmirc/.m2/repository/org/springframework/cloud/spring-cloud-consul-config/1.0.0.BUILD-SNAPSHOT/spring-cloud-consul-config-1.0.0.BUILD-SNAPSHOT.jar, file:/Users/jmirc/.m2/repository/org/springframework/cloud/spring-cloud-consul-discovery/1.0.0.BUILD-SNAPSHOT/spring-cloud-consul-discovery-1.0.0.BUILD-SNAPSHOT.jar, file:/Users/jmirc/.m2/repository/org/springframework/cloud/spring-cloud-consul-core/1.0.0.BUILD-SNAPSHOT/spring-cloud-consul-core-1.0.0.BUILD-SNAPSHOT.jar, file:/Users/jmirc/.m2/repository/org/springframework/cloud/spring-cloud-consul-ui/1.0.0.BUILD-SNAPSHOT/spring-cloud-consul-ui-1.0.0.BUILD-SNAPSHOT.jar, file:/Users/jmirc/.m2/repository/org/springframework/cloud/spring-cloud-starter-zuul/1.0.2.BUILD-SNAPSHOT/spring-cloud-starter-zuul-1.0.2.BUILD-20150427.150906-1.jar, file:/Users/jmirc/.m2/repository/org/springframework/cloud/spring-cloud-starter/1.0.2.BUILD-SNAPSHOT/spring-cloud-starter-1.0.2.BUILD-20150427.150843-1.jar, file:/Users/jmirc/.m2/repository/org/springframework/cloud/spring-cloud-context/1.0.2.BUILD-SNAPSHOT/spring-cloud-context-1.0.2.BUILD-20150617.043919-18.jar, file:/Users/jmirc/.m2/repository/org/springframework/cloud/spring-cloud-starter-hystrix/1.0.2.BUILD-SNAPSHOT/spring-cloud-starter-hystrix-1.0.2.BUILD-20150427.150854-1.jar, file:/Users/jmirc/.m2/repository/org/springframework/cloud/spring-cloud-netflix-core/1.0.2.BUILD-SNAPSHOT/spring-cloud-netflix-core-1.0.2.BUILD-20150430.190444-4.jar, file:/Users/jmirc/.m2/repository/com/netflix/hystrix/hystrix-core/1.4.4/hystrix-core-1.4.4.jar, file:/Users/jmirc/.m2/repository/io/reactivex/rxjava/1.0.7/rxjava-1.0.7.jar, file:/Users/jmirc/.m2/repository/com/netflix/hystrix/hystrix-metrics-event-stream/1.4.4/hystrix-metrics-event-stream-1.4.4.jar, file:/Users/jmirc/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.9.2/jackson-core-asl-1.9.2.jar, file:/Users/jmirc/.m2/repository/com/netflix/hystrix/hystrix-javanica/1.4.4/hystrix-javanica-1.4.4.jar, file:/Users/jmirc/.m2/repository/org/aspectj/aspectjweaver/1.8.5/aspectjweaver-1.8.5.jar, file:/Users/jmirc/.m2/repository/org/aspectj/aspectjrt/1.8.5/aspectjrt-1.8.5.jar, file:/Users/jmirc/.m2/repository/com/google/guava/guava/18.0/guava-18.0.jar, file:/Users/jmirc/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar, file:/Users/jmirc/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar, file:/Users/jmirc/.m2/repository/com/google/code/findbugs/jsr305/2.0.0/jsr305-2.0.0.jar, file:/Users/jmirc/.m2/repository/org/springframework/cloud/spring-cloud-starter-ribbon/1.0.2.BUILD-SNAPSHOT/spring-cloud-starter-ribbon-1.0.2.BUILD-20150427.150848-1.jar, file:/Users/jmirc/.m2/repository/com/netflix/ribbon/ribbon/2.0.0/ribbon-2.0.0.jar, file:/Users/jmirc/.m2/repository/com/netflix/ribbon/ribbon-transport/2.0.0/ribbon-transport-2.0.0.jar, file:/Users/jmirc/.m2/repository/io/reactivex/rxnetty-contexts/0.4.6/rxnetty-contexts-0.4.6.jar, file:/Users/jmirc/.m2/repository/io/reactivex/rxnetty-servo/0.4.6/rxnetty-servo-0.4.6.jar, file:/Users/jmirc/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar, file:/Users/jmirc/.m2/repository/io/reactivex/rxnetty/0.4.6/rxnetty-0.4.6.jar, file:/Users/jmirc/.m2/repository/io/netty/netty-codec-http/4.0.25.Final/netty-codec-http-4.0.25.Final.jar, file:/Users/jmirc/.m2/repository/io/netty/netty-codec/4.0.25.Final/netty-codec-4.0.25.Final.jar, file:/Users/jmirc/.m2/repository/io/netty/netty-handler/4.0.25.Final/netty-handler-4.0.25.Final.jar, file:/Users/jmirc/.m2/repository/io/netty/netty-transport-native-epoll/4.0.25.Final/netty-transport-native-epoll-4.0.25.Final.jar, file:/Users/jmirc/.m2/repository/io/netty/netty-common/4.0.25.Final/netty-common-4.0.25.Final.jar, file:/Users/jmirc/.m2/repository/io/netty/netty-buffer/4.0.25.Final/netty-buffer-4.0.25.Final.jar, file:/Users/jmirc/.m2/repository/io/netty/netty-transport/4.0.25.Final/netty-transport-4.0.25.Final.jar, file:/Users/jmirc/.m2/repository/commons-configuration/commons-configuration/1.8/commons-configuration-1.8.jar, file:/Users/jmirc/.m2/repository/com/netflix/ribbon/ribbon-core/2.0.0/ribbon-core-2.0.0.jar, file:/Users/jmirc/.m2/repository/com/google/code/findbugs/annotations/2.0.0/annotations-2.0.0.jar, file:/Users/jmirc/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar, file:/Users/jmirc/.m2/repository/com/netflix/ribbon/ribbon-httpclient/2.0.0/ribbon-httpclient-2.0.0.jar, file:/Users/jmirc/.m2/repository/com/sun/jersey/jersey-client/1.13/jersey-client-1.13.jar, file:/Users/jmirc/.m2/repository/com/sun/jersey/jersey-core/1.13/jersey-core-1.13.jar, file:/Users/jmirc/.m2/repository/com/sun/jersey/contribs/jersey-apache-client4/1.11/jersey-apache-client4-1.11.jar, file:/Users/jmirc/.m2/repository/com/netflix/ribbon/ribbon-loadbalancer/2.0.0/ribbon-loadbalancer-2.0.0.jar, file:/Users/jmirc/.m2/repository/com/netflix/netflix-commons/netflix-statistics/0.1.1/netflix-statistics-0.1.1.jar, file:/Users/jmirc/.m2/repository/com/netflix/rxjava/rxjava-core/0.20.7/rxjava-core-0.20.7.jar, file:/Users/jmirc/.m2/repository/com/netflix/zuul/zuul-core/1.0.28/zuul-core-1.0.28.jar, file:/Users/jmirc/.m2/repository/com/netflix/netflix-commons/netflix-commons-util/0.1.1/netflix-commons-util-0.1.1.jar, file:/Users/jmirc/.m2/repository/org/slf4j/slf4j-api/1.7.11/slf4j-api-1.7.11.jar, file:/Users/jmirc/.m2/repository/com/netflix/servo/servo-core/0.7.2/servo-core-0.7.2.jar, file:/Users/jmirc/.m2/repository/com/netflix/archaius/archaius-core/0.6.5/archaius-core-0.6.5.jar, file:/Users/jmirc/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar, file:/Users/jmirc/.m2/repository/joda-time/joda-time/2.5/joda-time-2.5.jar, file:/Users/jmirc/.m2/repository/org/apache/httpcomponents/httpcore/4.4/httpcore-4.4.jar, file:/Applications/IntelliJ%20IDEA%2014%20EAP.app/Contents/lib/idea_rt.jar]
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sampleProperties': Could not bind properties to [unknown] (target=sample, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:303)
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:250)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
    at demo.ConsulDemoApplication.main(ConsulDemoApplication.java:40)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:653)
    at java.util.ArrayList.get(ArrayList.java:429)
    at org.springframework.boot.bind.RelaxedDataBinder$BeanPath.isProperty(RelaxedDataBinder.java:531)

Here is the config structure inside consul

config/:
config/application/:
config/application/sample/:
config/application/sample/prop:test
config/MyTestProcessor/:
config/MyTestProcessor/sample/:
config/MyTestProcessor/sample/prop:test1

The exception is thrown because in the class ConsulPropertySource the code String key = getValue.getKey().replace(context, "").replace('/', '.'); replaces the key config/application/sample/ is replaced by config/application/sample. and the configuration tries to autowire the .(dot) which is not possible.

The code in the method init() does a check of the key if (StringUtils.hasText(key)). Instead of this check, the code should check if the key ends with a slash. If so the key and the value are not added like

    public void init() {
        Response<List<GetValue>> response = source.getKVValues(context,
                QueryParams.DEFAULT);
        List<GetValue> values = response.getValue();

        if (values != null) {
            for (GetValue getValue : values) {
                String key = getValue.getKey();
                if (!StringUtils.endsWithIgnoreCase(key, "/")) {
                    key = key.replace(context, "").replace('/', '.');
                    String value = getDecoded(getValue.getValue());
                    properties.put(key, value);
                }
            }
        }
    }

Port is set to null - NewService.Check

The port when a new instance of the NewService.Check is set to null when the healthCheckUrl is not set in the application.yml or in the bootstrap.yml.

In this case, the http method is set using the following code and the port is retrieved from the service. I think it should be retrieved from the properties.

/Users/jmirc/.m2/repository/org/springframework/cloud/spring-cloud-consul-discovery/1.0.0.M1/spring-cloud-consul-discovery-1.0.0.M1-sources.jar!/org/springframework/cloud/consul/discovery/ConsulLifecycle.java:77

check.setHttp(String.format("http://%s:%s%s", properties.getHostname(),
                    service.getPort(), properties.getHealthCheckPath()));

You can check the consul log to see the problem

2015/06/02 20:39:35 [WARN] agent: http request failed 'http://localhost:null/health': Get http://localhost:null/health: dial tcp: unknown port tcp/null

If I check the healthCheckUrl property, everything works perfectly like

spring:
  cloud:
    consul:
      discovery:
        healthCheckUrl: http://localhost:8080

/refresh fails due to a NullPointerException

When the ConsulPropertySource.java init() parses the consul folder information from the ?recurse call it is resulting in a key:value pair equal to "":null. This is true for all folder information. Because of this null value a bug in EnvironmentDecryptApplicationInitializer.java:127 is exposed where a NullPointerException is thrown from calling toString() on a null property.

Here's line 127 in EnvironmentDecryptApplicationInitializer.java:

String value = source.getProperty(key).toString();

Here's the full stack trace....

java.lang.NullPointerException: null
    at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.decrypt(EnvironmentDecryptApplicationInitializer.java:127) ~[spring-cloud-context-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.decrypt(EnvironmentDecryptApplicationInitializer.java:116) ~[spring-cloud-context-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.initialize(EnvironmentDecryptApplicationInitializer.java:81) ~[spring-cloud-context-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:567) ~[spring-boot-1.2.4.RELEASE.jar:1.2.4.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-1.2.4.RELEASE.jar:1.2.4.RELEASE]
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:139) [spring-boot-1.2.4.RELEASE.jar:1.2.4.RELEASE]
    at org.springframework.cloud.bootstrap.config.RefreshEndpoint.addConfigFilesToEnvironment(RefreshEndpoint.java:87) [spring-cloud-context-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.cloud.bootstrap.config.RefreshEndpoint.refresh(RefreshEndpoint.java:72) [spring-cloud-context-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.cloud.bootstrap.config.RefreshEndpoint.invoke(RefreshEndpoint.java:121) [spring-cloud-context-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.cloud.bootstrap.config.RefreshEndpoint.invoke(RefreshEndpoint.java:47) [spring-cloud-context-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke(EndpointMvcAdapter.java:61) [spring-boot-actuator-1.2.4.RELEASE.jar:1.2.4.RELEASE]
    at org.springframework.cloud.endpoint.GenericPostableMvcEndpoint.invoke(GenericPostableMvcEndpoint.java:50) [spring-cloud-context-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_31]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_31]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_31]
    at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_31]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) [javax.servlet-api-3.1.0.jar:3.1.0]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [javax.servlet-api-3.1.0.jar:3.1.0]
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808) [jetty-servlet-9.2.9.v20150224.jar:9.2.9.v20150224]
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587) [jetty-servlet-9.2.9.v20150224.jar:9.2.9.v20150224]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224]
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577) [jetty-security-9.2.9.v20150224.jar:9.2.9.v20150224]
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224]
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224]
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [jetty-servlet-9.2.9.v20150224.jar:9.2.9.v20150224]
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224]
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224]
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224]
    at org.eclipse.jetty.server.Server.handle(Server.java:497) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224]
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224]
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [jetty-server-9.2.9.v20150224.jar:9.2.9.v20150224]
    at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [jetty-io-9.2.9.v20150224.jar:9.2.9.v20150224]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [jetty-util-9.2.9.v20150224.jar:9.2.9.v20150224]
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [jetty-util-9.2.9.v20150224.jar:9.2.9.v20150224]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_31]

ConsulServerList returns unhealthy nodes.

Its using the consul catalog service: client.getCatalogService(this.serviceId, QueryParams.DEFAULT);
.. but shouldnt it be using the consul health endpoint with the ?passing param to only get healthy nodes?

Thanks
/Andreas

Need to remove eureka

Hi,

Currently it is like a non deterministic choice of consul vs eureka.

I think eureka needs to be removed or wired out.
The way we did in our fork is to remove netflix-common which imported eureka but probably it is too brutal.

@EnableConsulUi doesn't work

If I start consul without the ui parameter -ui-dir, I got a 404 error

Without -ui-dir

./consul agent -server -bootstrap-expect 1 -data-dir /tmp/consul

See the screenshot

screen shot 2015-06-01 at 22 04 35

With -ui-dir it works.

./consul agent -server -bootstrap-expect 1 -data-dir /tmp/consul -ui-dir `dirname $0`/ui

Erroneous health checks

When there are more than 1 services deployed on a single node and one of them is failing it will affect the discovery of any other service deployed on the same node.

The problem is caused by the following piece of code in the ServiceCheckServerListFilter class:

List<Check> nodeChecks = client.getHealthChecksForNode(consulServer.getNode(), QueryParams.DEFAULT).getValue();
boolean passingNodeChecks = true;
    for (Check check : nodeChecks) {
        if (check.getStatus() != Check.CheckStatus.PASSING) {
            passingNodeChecks = false;
            break;
        }
    }

getHealthChecksForNode returns health checks for all the registered services, in my case the list looks as follows:
[Node{node='ubuntu-abc', checkId='serfHealth', name='Serf Health Status', status=PASSING, notes='', output='Agent alive and reachable', serviceId='', serviceName=''}, Node{node='ubuntu-abc', checkId='service:my-gateway:8765', name='Service 'my-gateway' check', status=CRITICAL, notes='', output='', serviceId='my-gateway:8765', serviceName='my-gateway'}, Node{node='ubuntu-abc', checkId='service:my-ui:8888', name='Service 'my-ui' check', status=PASSING, notes='', output='', serviceId='my-ui:8888', serviceName='my-ui'}]

Please note that the service I am trying to look up (my-ui) is fine while another service (my-gateway) is failing. Unfortunately, the service ID is not taken into account in ServiceCheckServerListFilter and my-ui is not found.

A quick fix is to change:

if (check.getStatus() != Check.CheckStatus.PASSING) {

to:

if (passingServiceIds.contains(check.getServiceId()) 
&& check.getStatus() != Check.CheckStatus.PASSING) {

BTW, It looks like another method in the same class called getPassingServiceIds does not do anything in my case as the list returned here:

List<Check> serviceChecks = client.getHealthChecksForService(serviceId,
                    QueryParams.DEFAULT).getValue();

seems to be always empty (bug?).

Behavior of spring.cloud.consul.discovery.enabled is strange

@spencergibb, hi!

There are two settings: first is spring.cloud.discovery.enabled that come from spring cloud project, second is spring.cloud.consul.discovery.enabled from spring-cloud-consul.
If you set spring.cloud.discovery.enabled=true discovery other services will work as well cause spring.cloud.consul.discovery.enabled will be ignore. If you set spring.cloud.consul.discovery.enabled=true but turn off spring.cloud.discovery.enabled you cannot discovery other services but your service will be register as well.
So we have two options with different behaviors and if spring.cloud.discovery.enabled has a predictable behavior, spring.cloud.consul.discovery.enabled has a very strange behavior that confused me.
I think that spring.cloud.consul.discovery.enabled should be rename cause it affects to service registration in consul, not to discovery other services.

missing httpcore library

I just created a small app and I found an issue. A dependency to org.apache.httpcomponents:httpcore:4.4 seems to be missed. If I remove this dependency I got an error Caused by: java.lang.NoClassDefFoundError: org/apache/http/util/Args.

Here is my pom.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.test</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>consulDemo</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-parent</artifactId>
        <version>1.0.1.RELEASE</version>
        <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <start-class>demo.ConsulDemoApplication</start-class>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-consul-config</artifactId>
            <version>1.0.0.M1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-consul-discovery</artifactId>
            <version>1.0.0.M1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-consul-bus</artifactId>
            <version>1.0.0.M1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-consul-ui</artifactId>
            <version>1.0.0.M1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!--skip deploy -->
                <artifactId>maven-deploy-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

Reload properties raised an exception

When I try to refresh the properties using curl curl localhost:8080/refresh -d {} I got an exception.

java.lang.NullPointerException: null
    at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.decrypt(EnvironmentDecryptApplicationInitializer.java:127)
    at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.decrypt(EnvironmentDecryptApplicationInitializer.java:116)
    at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.initialize(EnvironmentDecryptApplicationInitializer.java:80)
    at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:567)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:139)
    at org.springframework.cloud.bootstrap.config.RefreshEndpoint.addConfigFilesToEnvironment(RefreshEndpoint.java:86)
    at org.springframework.cloud.bootstrap.config.RefreshEndpoint.refresh(RefreshEndpoint.java:72)
    at org.springframework.cloud.bootstrap.config.RefreshEndpoint.invoke(RefreshEndpoint.java:121)
    at org.springframework.cloud.bootstrap.config.RefreshEndpoint.invoke(RefreshEndpoint.java:47)

The issue is related to how the properties are loaded from the consul server by the class named ConsulPropertySource. The method init adds in the properties consul key or folder. No check to verify if the key is a folder is done. In this case, the name of the key is set to "" (empty) so when the refresh is called an exception is thrown.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.