Commit 1c5ba86d by Johannes Edmeier

fix compile errors

parent 051e46e6
<!--
~ Copyright 2014-2017 the original author or authors.
~ Copyright 2014-2018 the original author or authors.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
......@@ -29,10 +29,10 @@
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
</dependency>
<!--dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
</dependency-->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
......@@ -42,6 +42,10 @@
<artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-context</artifactId>
</dependency>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>
......
......@@ -69,20 +69,16 @@ public class InstancesServletProxyController extends AbstractInstancesProxyContr
.build(true)
.toUri();
return super.forward(instanceId, uri, request.getMethod(), request.getHeaders(), () -> {
try {
return BodyInserters.fromDataBuffers(DataBufferUtils.read(request.getBody(), this.bufferFactory, 4096));
} catch (IOException ex) {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, null, ex);
}
}).flatMap(clientResponse -> {
return super.forward(instanceId, uri, request.getMethod(), request.getHeaders(),
() -> BodyInserters.fromDataBuffers(
DataBufferUtils.readInputStream(request::getBody, this.bufferFactory, 4096)))
.flatMap(clientResponse -> {
response.setStatusCode(clientResponse.statusCode());
response.getHeaders().addAll(clientResponse.headers().asHttpHeaders());
Arrays.stream(HOP_BY_HOP_HEADERS).forEach(response.getHeaders()::remove);
try {
return DataBufferUtils.write(clientResponse.body(BodyExtractors.toDataBuffers()), response.getBody())
.doOnNext(DataBufferUtils::release)
.then();
return DataBufferUtils.write(clientResponse.body(BodyExtractors.toDataBuffers()),
response.getBody()).doOnNext(DataBufferUtils::release).then();
} catch (IOException ex) {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, null, ex);
}
......
/*
* Copyright 2014-2017 the original author or authors.
* Copyright 2014-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -142,7 +142,7 @@ public class LegacyEndpointConvertersTest {
}
private Flux<DataBuffer> read(String resourceName) {
return DataBufferUtils.read(LegacyEndpointConvertersTest.class.getResourceAsStream(resourceName), bufferFactory,
10);
return DataBufferUtils.readInputStream(
() -> LegacyEndpointConvertersTest.class.getResourceAsStream(resourceName), bufferFactory, 10);
}
}
\ No newline at end of file
/*
* Copyright 2014-2017 the original author or authors.
* Copyright 2014-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -23,10 +23,10 @@ import de.codecentric.boot.admin.client.registration.ServletApplicationFactory;
import javax.servlet.ServletContext;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.EndpointPathProvider;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.servlet.WebMvcEndpointManagementContextConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
......@@ -59,9 +59,9 @@ public class SpringBootAdminClientAutoConfiguration {
ManagementServerProperties management,
ServerProperties server,
ServletContext servletContext,
EndpointPathProvider endpointPathProvider,
PathMappedEndpoints pathMappedEndpoints,
WebEndpointProperties webEndpoint) {
return new ServletApplicationFactory(instance, management, server, servletContext, endpointPathProvider,
return new ServletApplicationFactory(instance, management, server, servletContext, pathMappedEndpoints,
webEndpoint);
}
}
......@@ -74,9 +74,9 @@ public class SpringBootAdminClientAutoConfiguration {
public ApplicationFactory applicationFactory(InstanceProperties instance,
ManagementServerProperties management,
ServerProperties server,
EndpointPathProvider endpointPathProvider,
PathMappedEndpoints pathMappedEndpoints,
WebEndpointProperties webEndpoint) {
return new DefaultApplicationFactory(instance, management, server, endpointPathProvider, webEndpoint);
return new DefaultApplicationFactory(instance, management, server, pathMappedEndpoints, webEndpoint);
}
}
......@@ -100,9 +100,9 @@ public class SpringBootAdminClientAutoConfiguration {
public ApplicationFactory applicationFactory(InstanceProperties instance,
ManagementServerProperties management,
ServerProperties server,
EndpointPathProvider endpointPathProvider,
PathMappedEndpoints pathMappedEndpoints,
WebEndpointProperties webEndpoint) {
return new DefaultApplicationFactory(instance, management, server, endpointPathProvider, webEndpoint);
return new DefaultApplicationFactory(instance, management, server, pathMappedEndpoints, webEndpoint);
}
@Bean
......
......@@ -24,9 +24,9 @@ import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.LinkedHashMap;
import java.util.Map;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.EndpointPathProvider;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.boot.web.server.Ssl;
......@@ -45,7 +45,7 @@ public class DefaultApplicationFactory implements ApplicationFactory {
private final InstanceProperties instance;
private final ServerProperties server;
private final ManagementServerProperties management;
private final EndpointPathProvider endpointPathProvider;
private final PathMappedEndpoints pathMappedEndpoints;
private final WebEndpointProperties webEndpoint;
private final OffsetDateTime timestamp;
private Integer localServerPort;
......@@ -54,13 +54,12 @@ public class DefaultApplicationFactory implements ApplicationFactory {
public DefaultApplicationFactory(InstanceProperties instance,
ManagementServerProperties management,
ServerProperties server,
EndpointPathProvider endpointPathProvider,
ServerProperties server, PathMappedEndpoints pathMappedEndpoints,
WebEndpointProperties webEndpoint) {
this.instance = instance;
this.management = management;
this.server = server;
this.endpointPathProvider = endpointPathProvider;
this.pathMappedEndpoints = pathMappedEndpoints;
this.webEndpoint = webEndpoint;
this.timestamp = OffsetDateTime.now();
}
......@@ -205,11 +204,11 @@ public class DefaultApplicationFactory implements ApplicationFactory {
}
protected String getHealthEndpointPath() {
String health = endpointPathProvider.getPath("health");
String health = pathMappedEndpoints.getPath("health");
if (StringUtils.hasText(health)) {
return health;
}
String status = endpointPathProvider.getPath("status");
String status = pathMappedEndpoints.getPath("status");
if (StringUtils.hasText(status)) {
return status;
}
......
/*
* Copyright 2014-2017 the original author or authors.
* Copyright 2014-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -19,9 +19,9 @@ package de.codecentric.boot.admin.client.registration;
import de.codecentric.boot.admin.client.config.InstanceProperties;
import javax.servlet.ServletContext;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.EndpointPathProvider;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.web.util.UriComponentsBuilder;
......@@ -34,9 +34,9 @@ public class ServletApplicationFactory extends DefaultApplicationFactory {
ManagementServerProperties management,
ServerProperties server,
ServletContext servletContext,
EndpointPathProvider endpointPathProvider,
PathMappedEndpoints pathMappedEndpoints,
WebEndpointProperties webEndpoint) {
super(instance, management, server, endpointPathProvider, webEndpoint);
super(instance, management, server, pathMappedEndpoints, webEndpoint);
this.servletContext = servletContext;
this.servlet = server.getServlet();
this.managementServlet = management.getServlet();
......
/*
* Copyright 2014-2017 the original author or authors.
* Copyright 2014-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -22,9 +22,9 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.EndpointPathProvider;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.boot.web.server.Ssl;
......@@ -40,11 +40,11 @@ public class DefaultApplicationFactoryTest {
private InstanceProperties instanceProperties = new InstanceProperties();
private ServerProperties server = new ServerProperties();
private ManagementServerProperties management = new ManagementServerProperties();
private EndpointPathProvider endpointPathProvider = mock(EndpointPathProvider.class);
private PathMappedEndpoints pathMappedEndpoints = mock(PathMappedEndpoints.class);
private WebEndpointProperties webEndpoint = new WebEndpointProperties();
private DefaultApplicationFactory factory = new DefaultApplicationFactory(instanceProperties, management, server,
endpointPathProvider, webEndpoint);
pathMappedEndpoints, webEndpoint);
@Before
public void setup() {
......@@ -54,7 +54,7 @@ public class DefaultApplicationFactoryTest {
@Test
public void test_mgmtPortPath() {
webEndpoint.setBasePath("/admin");
when(endpointPathProvider.getPath("health")).thenReturn("/admin/alive");
when(pathMappedEndpoints.getPath("health")).thenReturn("/admin/alive");
publishApplicationReadyEvent(factory, 8080, 8081);
Application app = factory.createApplication();
......@@ -65,7 +65,7 @@ public class DefaultApplicationFactoryTest {
@Test
public void test_default() {
when(endpointPathProvider.getPath("health")).thenReturn("/actuator/health");
when(pathMappedEndpoints.getPath("health")).thenReturn("/actuator/health");
publishApplicationReadyEvent(factory, 8080, null);
Application app = factory.createApplication();
......@@ -78,7 +78,7 @@ public class DefaultApplicationFactoryTest {
public void test_ssl() {
server.setSsl(new Ssl());
server.getSsl().setEnabled(true);
when(endpointPathProvider.getPath("health")).thenReturn("/actuator/health");
when(pathMappedEndpoints.getPath("health")).thenReturn("/actuator/health");
publishApplicationReadyEvent(factory, 8080, null);
Application app = factory.createApplication();
......@@ -91,7 +91,7 @@ public class DefaultApplicationFactoryTest {
public void test_ssl_management() {
management.setSsl(new Ssl());
management.getSsl().setEnabled(true);
when(endpointPathProvider.getPath("health")).thenReturn("/actuator/alive");
when(pathMappedEndpoints.getPath("health")).thenReturn("/actuator/alive");
publishApplicationReadyEvent(factory, 8080, 9090);
Application app = factory.createApplication();
......@@ -103,7 +103,7 @@ public class DefaultApplicationFactoryTest {
@Test
public void test_preferIpAddress_serveraddress_missing() {
instanceProperties.setPreferIp(true);
when(endpointPathProvider.getPath("health")).thenReturn("/application/alive");
when(pathMappedEndpoints.getPath("health")).thenReturn("/application/alive");
publishApplicationReadyEvent(factory, 8080, null);
Application app = factory.createApplication();
......@@ -113,7 +113,7 @@ public class DefaultApplicationFactoryTest {
@Test
public void test_preferIpAddress_managementaddress_missing() {
instanceProperties.setPreferIp(true);
when(endpointPathProvider.getPath("health")).thenReturn("/application/alive");
when(pathMappedEndpoints.getPath("health")).thenReturn("/application/alive");
publishApplicationReadyEvent(factory, 8080, 8081);
Application app = factory.createApplication();
......@@ -125,7 +125,7 @@ public class DefaultApplicationFactoryTest {
instanceProperties.setPreferIp(true);
server.setAddress(InetAddress.getByName("127.0.0.1"));
management.setAddress(InetAddress.getByName("127.0.0.2"));
when(endpointPathProvider.getPath("health")).thenReturn("/actuator/health");
when(pathMappedEndpoints.getPath("health")).thenReturn("/actuator/health");
publishApplicationReadyEvent(factory, 8080, 8081);
Application app = factory.createApplication();
......@@ -151,7 +151,7 @@ public class DefaultApplicationFactoryTest {
instanceProperties.setManagementBaseUrl("http://management:8090");
instanceProperties.setServiceBaseUrl("http://service:80");
webEndpoint.setBasePath("/admin");
when(endpointPathProvider.getPath("health")).thenReturn("/admin/health");
when(pathMappedEndpoints.getPath("health")).thenReturn("/admin/health");
Application app = factory.createApplication();
assertThat(app.getServiceUrl()).isEqualTo("http://service:80/");
......@@ -163,7 +163,7 @@ public class DefaultApplicationFactoryTest {
public void test_service_baseUrl() {
instanceProperties.setServiceBaseUrl("http://service:80");
webEndpoint.setBasePath("/admin");
when(endpointPathProvider.getPath("health")).thenReturn("/admin/health");
when(pathMappedEndpoints.getPath("health")).thenReturn("/admin/health");
Application app = factory.createApplication();
assertThat(app.getServiceUrl()).isEqualTo("http://service:80/");
......
/*
* Copyright 2014-2017 the original author or authors.
* Copyright 2014-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -22,9 +22,9 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.EndpointPathProvider;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.boot.web.server.WebServer;
......@@ -40,10 +40,10 @@ public class ServletApplicationFactoryTest {
private ServerProperties server = new ServerProperties();
private ManagementServerProperties management = new ManagementServerProperties();
private MockServletContext servletContext = new MockServletContext();
private EndpointPathProvider endpointPathProvider = mock(EndpointPathProvider.class);
private PathMappedEndpoints pathMappedEndpoints = mock(PathMappedEndpoints.class);
private WebEndpointProperties webEndpoint = new WebEndpointProperties();
private ServletApplicationFactory factory = new ServletApplicationFactory(instance, management, server,
servletContext, endpointPathProvider, webEndpoint);
servletContext, pathMappedEndpoints, webEndpoint);
@Before
public void setup() {
......@@ -54,7 +54,7 @@ public class ServletApplicationFactoryTest {
public void test_contextPath_mgmtPath() {
servletContext.setContextPath("app");
webEndpoint.setBasePath("/admin");
when(endpointPathProvider.getPath("health")).thenReturn("/admin/health");
when(pathMappedEndpoints.getPath("health")).thenReturn("/admin/health");
publishApplicationReadyEvent(factory, 8080, null);
Application app = factory.createApplication();
......@@ -67,7 +67,7 @@ public class ServletApplicationFactoryTest {
public void test_contextPath_mgmtPortPath() {
servletContext.setContextPath("app");
webEndpoint.setBasePath("/admin");
when(endpointPathProvider.getPath("health")).thenReturn("/admin/health");
when(pathMappedEndpoints.getPath("health")).thenReturn("/admin/health");
publishApplicationReadyEvent(factory, 8080, 8081);
Application app = factory.createApplication();
......@@ -79,7 +79,7 @@ public class ServletApplicationFactoryTest {
@Test
public void test_contextPath() {
servletContext.setContextPath("app");
when(endpointPathProvider.getPath("health")).thenReturn("/actuator/health");
when(pathMappedEndpoints.getPath("health")).thenReturn("/actuator/health");
publishApplicationReadyEvent(factory, 80, null);
Application app = factory.createApplication();
......@@ -92,7 +92,7 @@ public class ServletApplicationFactoryTest {
public void test_servletPath() {
server.getServlet().setPath("app");
servletContext.setContextPath("srv");
when(endpointPathProvider.getPath("health")).thenReturn("/actuator/health");
when(pathMappedEndpoints.getPath("health")).thenReturn("/actuator/health");
publishApplicationReadyEvent(factory, 80, null);
Application app = factory.createApplication();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment