Improve null-safety of module/spring-boot-actuator
See gh-46926
This commit is contained in:
parent
552c145213
commit
f51f872c28
|
@ -61,7 +61,7 @@ public class AuditEvent implements Serializable {
|
|||
* @param type the event type
|
||||
* @param data the event data
|
||||
*/
|
||||
public AuditEvent(String principal, String type, Map<String, @Nullable Object> data) {
|
||||
public AuditEvent(@Nullable String principal, String type, Map<String, @Nullable Object> data) {
|
||||
this(Instant.now(), principal, type, data);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class AuditEvent implements Serializable {
|
|||
* @param type the event type
|
||||
* @param data the event data in the form 'key=value' or simply 'key'
|
||||
*/
|
||||
public AuditEvent(String principal, String type, String... data) {
|
||||
public AuditEvent(@Nullable String principal, String type, String... data) {
|
||||
this(Instant.now(), principal, type, convert(data));
|
||||
}
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ public class AuditEventsEndpoint {
|
|||
}
|
||||
|
||||
@ReadOperation
|
||||
public AuditEventsDescriptor events(@OptionalParameter String principal, @OptionalParameter OffsetDateTime after,
|
||||
@OptionalParameter String type) {
|
||||
public AuditEventsDescriptor events(@OptionalParameter @Nullable String principal,
|
||||
@OptionalParameter @Nullable OffsetDateTime after, @OptionalParameter @Nullable String type) {
|
||||
List<AuditEvent> events = this.auditEventRepository.find(principal, getInstant(after), type);
|
||||
return new AuditEventsDescriptor(events);
|
||||
}
|
||||
|
|
|
@ -81,12 +81,12 @@ public class EnvironmentEndpoint {
|
|||
}
|
||||
|
||||
@ReadOperation
|
||||
public EnvironmentDescriptor environment(@OptionalParameter String pattern) {
|
||||
public EnvironmentDescriptor environment(@OptionalParameter @Nullable String pattern) {
|
||||
boolean showUnsanitized = this.showValues.isShown(true);
|
||||
return getEnvironmentDescriptor(pattern, showUnsanitized);
|
||||
}
|
||||
|
||||
EnvironmentDescriptor getEnvironmentDescriptor(String pattern, boolean showUnsanitized) {
|
||||
EnvironmentDescriptor getEnvironmentDescriptor(@Nullable String pattern, boolean showUnsanitized) {
|
||||
if (StringUtils.hasText(pattern)) {
|
||||
return getEnvironmentDescriptor(Pattern.compile(pattern).asPredicate(), showUnsanitized);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.springframework.boot.actuate.env;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.SecurityContext;
|
||||
import org.springframework.boot.actuate.endpoint.Show;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.OptionalParameter;
|
||||
|
@ -51,7 +53,8 @@ public class EnvironmentEndpointWebExtension {
|
|||
}
|
||||
|
||||
@ReadOperation
|
||||
public EnvironmentDescriptor environment(SecurityContext securityContext, @OptionalParameter String pattern) {
|
||||
public EnvironmentDescriptor environment(SecurityContext securityContext,
|
||||
@OptionalParameter @Nullable String pattern) {
|
||||
boolean showUnsanitized = this.showValues.isShown(securityContext, this.roles);
|
||||
return this.delegate.getEnvironmentDescriptor(pattern, showUnsanitized);
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ public class LoggersEndpoint {
|
|||
}
|
||||
|
||||
@WriteOperation
|
||||
public void configureLogLevel(@Selector String name, @OptionalParameter LogLevel configuredLevel) {
|
||||
public void configureLogLevel(@Selector String name, @OptionalParameter @Nullable LogLevel configuredLevel) {
|
||||
Assert.notNull(name, "'name' must not be empty");
|
||||
LoggerGroup group = this.loggerGroups.get(name);
|
||||
if (group != null && group.hasMembers()) {
|
||||
|
|
|
@ -78,7 +78,7 @@ public class HeapDumpWebEndpoint {
|
|||
}
|
||||
|
||||
@ReadOperation
|
||||
public WebEndpointResponse<Resource> heapDump(@OptionalParameter Boolean live) {
|
||||
public WebEndpointResponse<Resource> heapDump(@OptionalParameter @Nullable Boolean live) {
|
||||
try {
|
||||
if (this.lock.tryLock(this.timeout, TimeUnit.MILLISECONDS)) {
|
||||
try {
|
||||
|
@ -101,7 +101,7 @@ public class HeapDumpWebEndpoint {
|
|||
return new WebEndpointResponse<>(WebEndpointResponse.STATUS_TOO_MANY_REQUESTS);
|
||||
}
|
||||
|
||||
private Resource dumpHeap(Boolean live) throws IOException, InterruptedException {
|
||||
private Resource dumpHeap(@Nullable Boolean live) throws IOException, InterruptedException {
|
||||
if (this.heapDumper == null) {
|
||||
this.heapDumper = createHeapDumper();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue