Repository: spring-cloud/spring-cloud-config
Issue: config.client.version no longer in Dalston

I was using Camden.SR7 on my Spring Cloud Config Server and there's a config.client.version and it changes everytime the properties get refreshed.

{"name":"application.properties","profiles":["master"],"label":"master",**"version":"9ad0fd174feb0cdbc5ab73753e64be061af2ba3b"**,"state":null,"propertySources":[]}

But on Dalston, the version is null, is this a feature or a bug?

Changed files:
spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/CompositeEnvironmentRepositoryTests.java
spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/CompositeEnvironmentRepository.java

diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/CompositeEnvironmentRepository.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/CompositeEnvironmentRepository.java
index 77d2f44f..f58509f2 100644
--- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/CompositeEnvironmentRepository.java
+++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/CompositeEnvironmentRepository.java
@@ -41,8 +41,15 @@ public class CompositeEnvironmentRepository implements EnvironmentRepository {
 	@Override
 	public Environment findOne(String application, String profile, String label) {
 		Environment env = new Environment(application, new String[]{profile}, label, null, null);
-		for(EnvironmentRepository repo : environmentRepositories) {
-			env.addAll(repo.findOne(application, profile, label).getPropertySources());
+		if(environmentRepositories.size() == 1) {
+			Environment envRepo = environmentRepositories.get(0).findOne(application, profile, label);
+			env.addAll(envRepo.getPropertySources());
+			env.setVersion(envRepo.getVersion());
+			env.setState(envRepo.getState());
+		} else {
+			for (EnvironmentRepository repo : environmentRepositories) {
+				env.addAll(repo.findOne(application, profile, label).getPropertySources());
+			}
 		}
 		return env;
 	}
diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/CompositeEnvironmentRepositoryTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/CompositeEnvironmentRepositoryTests.java
index b1cc7904..138f9f56 100644
--- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/CompositeEnvironmentRepositoryTests.java
+++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/CompositeEnvironmentRepositoryTests.java
@@ -110,4 +110,38 @@ public class CompositeEnvironmentRepositoryTests {
 		assertEquals(sLoc4, locationStrings[3]);
 		assertEquals(sLoc1, locationStrings[4]);
 	}
+
+	@Test
+	public void testVersion() {
+		PropertySource p1 = mock(PropertySource.class);
+		doReturn("p1").when(p1).getName();
+		PropertySource p2 = mock(PropertySource.class);
+		doReturn("p2").when(p2).getName();
+		String sLoc1 = "loc1";
+		String sLoc2 = "loc2";
+		Environment e1 = new Environment("app", "dev");
+		e1.add(p1);
+		e1.setVersion("1");
+		e1.setState("state");
+		Environment e2 = new Environment("app", "dev");
+		e2.add(p2);
+		e2.setVersion("2");
+		e2.setState("state2");
+		SearchPathLocator.Locations loc1 = new SearchPathLocator.Locations("app", "dev", "label", "version", new String[]{sLoc1});
+		SearchPathLocator.Locations loc2 = new SearchPathLocator.Locations("app", "dev", "label", "version", new String[]{sLoc1, sLoc2});
+		List<EnvironmentRepository> repos = new ArrayList<EnvironmentRepository>();
+		repos.add(new TestOrderedEnvironmentRepository(3, e1, loc1));
+		List<EnvironmentRepository> repos2 = new ArrayList<EnvironmentRepository>();
+		repos2.add(new TestOrderedEnvironmentRepository(3, e1, loc1));
+		repos2.add(new TestOrderedEnvironmentRepository(3, e2, loc2));
+		SearchPathCompositeEnvironmentRepository compositeRepo = new SearchPathCompositeEnvironmentRepository(repos);
+		SearchPathCompositeEnvironmentRepository multiCompositeRepo = new SearchPathCompositeEnvironmentRepository(repos2);
+		Environment env = compositeRepo.findOne("app", "dev", "label");
+		assertEquals("1", env.getVersion());
+		assertEquals("state", env.getState());
+		Environment multiEnv = multiCompositeRepo.findOne("app", "dev", "label");
+		assertEquals(null, multiEnv.getVersion());
+		assertEquals(null, multiEnv.getState());
+
+	}
 }