Merge branch '1.5.x'
This commit is contained in:
@@ -68,17 +68,19 @@ public class LoggersMvcEndpoint extends EndpointMvcAdapter {
|
||||
// disabled
|
||||
return getDisabledResponse();
|
||||
}
|
||||
LogLevel logLevel;
|
||||
try {
|
||||
String level = configuration.get("configuredLevel");
|
||||
logLevel = level == null ? null : LogLevel.valueOf(level.toUpperCase());
|
||||
LogLevel logLevel = getLogLevel(configuration);
|
||||
this.delegate.setLogLevel(name, logLevel);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
return ResponseEntity.badRequest().build();
|
||||
}
|
||||
}
|
||||
|
||||
this.delegate.setLogLevel(name, logLevel);
|
||||
return ResponseEntity.ok().build();
|
||||
private LogLevel getLogLevel(Map<String, String> configuration) {
|
||||
String level = configuration.get("configuredLevel");
|
||||
return (level == null ? null : LogLevel.valueOf(level.toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,13 +41,10 @@ public class SolrHealthIndicator extends AbstractHealthIndicator {
|
||||
CoreAdminRequest request = new CoreAdminRequest();
|
||||
request.setAction(CoreAdminParams.CoreAdminAction.STATUS);
|
||||
CoreAdminResponse response = request.process(this.solrClient);
|
||||
int status = response.getStatus();
|
||||
if (status == 0) {
|
||||
builder.up().withDetail("solrStatus", "OK");
|
||||
}
|
||||
else {
|
||||
builder.down().withDetail("solrStatus", status);
|
||||
}
|
||||
int statusCode = response.getStatus();
|
||||
Status status = (statusCode == 0 ? Status.UP : Status.DOWN);
|
||||
builder.status(status).withDetail("solrStatus",
|
||||
(statusCode == 0 ? "OK" : statusCode));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
|
||||
add(trace, Include.USER_PRINCIPAL, "userPrincipal",
|
||||
(userPrincipal == null ? null : userPrincipal.getName()));
|
||||
if (isIncluded(Include.PARAMETERS)) {
|
||||
trace.put("parameters", getParameterMap(request));
|
||||
trace.put("parameters", getParameterMapCopy(request));
|
||||
}
|
||||
add(trace, Include.QUERY_STRING, "query", request.getQueryString());
|
||||
add(trace, Include.AUTH_TYPE, "authType", request.getAuthType());
|
||||
@@ -190,10 +190,8 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
|
||||
return value;
|
||||
}
|
||||
|
||||
private Map<String, String[]> getParameterMap(HttpServletRequest request) {
|
||||
Map<String, String[]> map = new LinkedHashMap<String, String[]>();
|
||||
map.putAll(request.getParameterMap());
|
||||
return map;
|
||||
private Map<String, String[]> getParameterMapCopy(HttpServletRequest request) {
|
||||
return new LinkedHashMap<String, String[]>(request.getParameterMap());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -66,7 +66,7 @@ public class TraceWebFilterAutoConfigurationTests {
|
||||
public void skipsFilterIfPropertyDisabled() throws Exception {
|
||||
load("endpoints.trace.filter.enabled:false");
|
||||
assertThat(this.context.getBeansOfType(WebRequestTraceFilter.class).size())
|
||||
.isEqualTo(0);
|
||||
.isEqualTo(0);
|
||||
}
|
||||
|
||||
private void load(String... environment) {
|
||||
@@ -74,16 +74,16 @@ public class TraceWebFilterAutoConfigurationTests {
|
||||
}
|
||||
|
||||
private void load(Class<?> config, String... environment) {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||
EnvironmentTestUtils.addEnvironment(ctx, environment);
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
EnvironmentTestUtils.addEnvironment(context, environment);
|
||||
if (config != null) {
|
||||
ctx.register(config);
|
||||
context.register(config);
|
||||
}
|
||||
ctx.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
TraceRepositoryAutoConfiguration.class,
|
||||
TraceWebFilterAutoConfiguration.class);
|
||||
ctx.refresh();
|
||||
this.context = ctx;
|
||||
context.register(PropertyPlaceholderAutoConfiguration.class,
|
||||
TraceRepositoryAutoConfiguration.class,
|
||||
TraceWebFilterAutoConfiguration.class);
|
||||
context.refresh();
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -31,9 +31,9 @@ import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.isNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
@@ -68,7 +68,7 @@ public class SolrHealthIndicatorTests {
|
||||
public void solrIsUp() throws Exception {
|
||||
SolrClient solrClient = mock(SolrClient.class);
|
||||
given(solrClient.request(any(CoreAdminRequest.class), isNull()))
|
||||
.willReturn(mockResponse(0));
|
||||
.willReturn(mockResponse(0));
|
||||
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
|
||||
Health health = healthIndicator.health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
@@ -79,7 +79,7 @@ public class SolrHealthIndicatorTests {
|
||||
public void solrIsUpAndRequestFailed() throws Exception {
|
||||
SolrClient solrClient = mock(SolrClient.class);
|
||||
given(solrClient.request(any(CoreAdminRequest.class), isNull()))
|
||||
.willReturn(mockResponse(400));
|
||||
.willReturn(mockResponse(400));
|
||||
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
|
||||
Health health = healthIndicator.health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
||||
@@ -90,7 +90,7 @@ public class SolrHealthIndicatorTests {
|
||||
public void solrIsDown() throws Exception {
|
||||
SolrClient solrClient = mock(SolrClient.class);
|
||||
given(solrClient.request(any(CoreAdminRequest.class), isNull()))
|
||||
.willThrow(new IOException("Connection failed"));
|
||||
.willThrow(new IOException("Connection failed"));
|
||||
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
|
||||
Health health = healthIndicator.health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
||||
|
||||
Reference in New Issue
Block a user