Use HttpHeaders explicitly in endpoint method
Otherwise headers become case sensitive in downstream code. Fixes gh-240
This commit is contained in:
@@ -41,9 +41,9 @@ import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.PatternMatchUtils;
|
||||
|
||||
import lombok.extern.apachecommons.CommonsLog;
|
||||
@@ -176,9 +176,8 @@ public class FileMonitorConfiguration implements SmartLifecycle, ResourceLoaderA
|
||||
@Scheduled(fixedRateString = "${spring.cloud.config.server.monitor.fixedDelay:5000}")
|
||||
public void poll() {
|
||||
for (File file : filesFromEvents()) {
|
||||
this.endpoint.notifyByPath(new LinkedMultiValueMap<String, String>(),
|
||||
Collections.<String, Object> singletonMap("path",
|
||||
file.getAbsolutePath()));
|
||||
this.endpoint.notifyByPath(new HttpHeaders(), Collections
|
||||
.<String, Object> singletonMap("path", file.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationEventPublisherAware;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@@ -75,7 +75,7 @@ public class PropertyPathEndpoint
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public Set<String> notifyByPath(@RequestHeader MultiValueMap<String, String> headers,
|
||||
public Set<String> notifyByPath(@RequestHeader HttpHeaders headers,
|
||||
@RequestBody Map<String, Object> request) {
|
||||
PropertyPathNotification notification = this.extractor.extract(headers, request);
|
||||
if (notification != null) {
|
||||
@@ -100,7 +100,7 @@ public class PropertyPathEndpoint
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||
public Set<String> notifyByForm(@RequestHeader MultiValueMap<String, String> headers, @RequestParam("path") List<String> request) {
|
||||
public Set<String> notifyByForm(@RequestHeader HttpHeaders headers, @RequestParam("path") List<String> request) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String key = "path";
|
||||
map.put(key, request);
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -46,9 +46,8 @@ public class PropertyPathEndpointTests {
|
||||
|
||||
@Test
|
||||
public void testNotifyByForm() throws Exception {
|
||||
assertEquals(0,
|
||||
this.endpoint.notifyByForm(new LinkedMultiValueMap<String, String>(),
|
||||
new ArrayList<String>()).size());
|
||||
assertEquals(0, this.endpoint
|
||||
.notifyByForm(new HttpHeaders(), new ArrayList<String>()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -57,16 +56,15 @@ public class PropertyPathEndpointTests {
|
||||
request.add("/foo/bar.properties");
|
||||
request.add("/application.properties");
|
||||
assertEquals("[bar, *]",
|
||||
this.endpoint
|
||||
.notifyByForm(new LinkedMultiValueMap<String, String>(), request)
|
||||
.toString());
|
||||
this.endpoint.notifyByForm(new HttpHeaders(), request).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotifyAll() throws Exception {
|
||||
assertEquals("[*]", this.endpoint
|
||||
.notifyByPath(new LinkedMultiValueMap<String, String>(), Collections
|
||||
.<String, Object> singletonMap("path", "application.yml"))
|
||||
assertEquals("[*]",
|
||||
this.endpoint
|
||||
.notifyByPath(new HttpHeaders(), Collections
|
||||
.<String, Object> singletonMap("path", "application.yml"))
|
||||
.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user