Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ internal sealed class RouteMappingsEndpointMiddleware(
IRouteMappingsEndpointHandler endpointHandler, IOptionsMonitor<ManagementOptions> managementOptionsMonitor, ILoggerFactory loggerFactory)
: EndpointMiddleware<object?, RouteMappingsResponse>(endpointHandler, managementOptionsMonitor, loggerFactory)
{
// There is no difference between v2 and v3 responses. This override is a workaround for Spring Boot Admin: https://github.com/codecentric/spring-boot-admin/issues/4001.
private protected override string ContentType => "application/vnd.spring-boot.actuator.v2+json";

protected override async Task<RouteMappingsResponse> InvokeEndpointHandlerAsync(object? request, CancellationToken cancellationToken)
{
return await EndpointHandler.InvokeAsync(request, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public async Task StartAsync(CancellationToken cancellationToken)
{
SpringBootAdminClientOptions clientOptions = _clientOptionsMonitor.CurrentValue;

if (clientOptions.Url == null)
{
throw new InvalidOperationException("Spring Boot Admin Server Url must be provided in options.");
}

_logger.LogInformation("Registering with Spring Boot Admin Server at {Url}", clientOptions.Url);

if (clientOptions.ApplicationName == null || !Uri.TryCreate(clientOptions.BasePath, UriKind.Absolute, out Uri? baseUri))
Expand All @@ -69,7 +74,7 @@ public async Task StartAsync(CancellationToken cancellationToken)
}
catch (Exception exception) when (!exception.IsCancellation())
{
_logger.LogError(exception, "Error connecting to Spring Boot Admin Server: {Message}", exception.Message);
_logger.LogError(exception, "Error connecting to Spring Boot Admin Server.");
return;
}

Expand Down Expand Up @@ -132,7 +137,7 @@ public async Task StopAsync(CancellationToken cancellationToken)
}
catch (Exception exception) when (!exception.IsCancellation())
{
_logger.LogError(exception, "Error connecting to Spring Boot Admin Server: {Message}", exception.Message);
_logger.LogError(exception, "Error connecting to Spring Boot Admin Server.");
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public sealed class ActuatorContentNegotiationTests
[InlineData("httpexchanges", SpringBootStandardAccept, ActuatorV3)]
[InlineData("info", $"{ActuatorV3},{SpringBootStandardAccept}", ActuatorV3)]
[InlineData("loggers", SpringBootStandardAccept, ActuatorV3)]
[InlineData("mappings", SpringBootStandardAccept, ActuatorV2)]
[InlineData("mappings", SpringBootStandardAccept, ActuatorV3)]
[InlineData("threaddump", SpringBootStandardAccept, ActuatorV3)]
[Theory]
public async Task Responses_for_SpringBootAdmin_match_expectations(string endpoint, string acceptHeader, string responseContentType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ public async Task Returns_endpoints_for_RouteMappings_actuator(HostBuilderType h
"dispatcherServlet": [
{
"handler": "/actuator/mappings",
"predicate": "{GET [/actuator/mappings], produces [application/vnd.spring-boot.actuator.v2+json]}",
"predicate": "{GET [/actuator/mappings], produces [application/vnd.spring-boot.actuator.v3+json]}",
"details": {
"handlerMethod": {
"className": "Steeltoe.Management.Endpoint.Middleware.EndpointMiddleware`2",
Expand All @@ -668,7 +668,7 @@ public async Task Returns_endpoints_for_RouteMappings_actuator(HostBuilderType h
"consumes": [],
"produces": [
{
"mediaType": "application/vnd.spring-boot.actuator.v2+json",
"mediaType": "application/vnd.spring-boot.actuator.v3+json",
"negated": false
}
],
Expand Down
Loading