Skip to content

Commit 4072a74

Browse files
committed
WIP
1 parent b812368 commit 4072a74

File tree

7 files changed

+24
-20
lines changed

7 files changed

+24
-20
lines changed

module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEvent.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ public class AuditEvent implements Serializable {
5353

5454
private final String type;
5555

56-
private final Map<String, Object> data;
56+
private final Map<String, @Nullable Object> data;
5757

5858
/**
5959
* Create a new audit event for the current time.
6060
* @param principal the user principal responsible
6161
* @param type the event type
6262
* @param data the event data
6363
*/
64-
public AuditEvent(String principal, String type, Map<String, Object> data) {
64+
public AuditEvent(String principal, String type, Map<String, @Nullable Object> data) {
6565
this(Instant.now(), principal, type, data);
6666
}
6767

@@ -83,7 +83,7 @@ public AuditEvent(String principal, String type, String... data) {
8383
* @param type the event type
8484
* @param data the event data
8585
*/
86-
public AuditEvent(Instant timestamp, @Nullable String principal, String type, Map<String, Object> data) {
86+
public AuditEvent(Instant timestamp, @Nullable String principal, String type, Map<String, @Nullable Object> data) {
8787
Assert.notNull(timestamp, "'timestamp' must not be null");
8888
Assert.notNull(type, "'type' must not be null");
8989
this.timestamp = timestamp;
@@ -92,8 +92,8 @@ public AuditEvent(Instant timestamp, @Nullable String principal, String type, Ma
9292
this.data = Collections.unmodifiableMap(data);
9393
}
9494

95-
private static Map<String, Object> convert(String[] data) {
96-
Map<String, Object> result = new HashMap<>();
95+
private static Map<String, @Nullable Object> convert(String[] data) {
96+
Map<String, @Nullable Object> result = new HashMap<>();
9797
for (String entry : data) {
9898
int index = entry.indexOf('=');
9999
if (index != -1) {
@@ -135,7 +135,7 @@ public String getType() {
135135
* Returns the event data.
136136
* @return the event data
137137
*/
138-
public Map<String, Object> getData() {
138+
public Map<String, @Nullable Object> getData() {
139139
return this.data;
140140
}
141141

module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/listener/AuditApplicationEvent.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.time.Instant;
2020
import java.util.Map;
2121

22+
import org.jspecify.annotations.Nullable;
23+
2224
import org.springframework.boot.actuate.audit.AuditEvent;
2325
import org.springframework.context.ApplicationEvent;
2426
import org.springframework.util.Assert;
@@ -41,7 +43,7 @@ public class AuditApplicationEvent extends ApplicationEvent {
4143
* @param data the event data
4244
* @see AuditEvent#AuditEvent(String, String, Map)
4345
*/
44-
public AuditApplicationEvent(String principal, String type, Map<String, Object> data) {
46+
public AuditApplicationEvent(String principal, String type, Map<String, @Nullable Object> data) {
4547
this(new AuditEvent(principal, type, data));
4648
}
4749

@@ -66,7 +68,7 @@ public AuditApplicationEvent(String principal, String type, String... data) {
6668
* @param data the event data
6769
* @see AuditEvent#AuditEvent(Instant, String, String, Map)
6870
*/
69-
public AuditApplicationEvent(Instant timestamp, String principal, String type, Map<String, Object> data) {
71+
public AuditApplicationEvent(Instant timestamp, String principal, String type, Map<String, @Nullable Object> data) {
7072
this(new AuditEvent(timestamp, principal, type, data));
7173
}
7274

module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/availability/AvailabilityStateHealthIndicator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class AvailabilityStateHealthIndicator extends AbstractHealthIndicator {
4545

4646
private final Class<? extends AvailabilityState> stateType;
4747

48-
private final Map<AvailabilityState, Status> statusMappings = new HashMap<>();
48+
private final Map<@Nullable AvailabilityState, Status> statusMappings = new HashMap<>();
4949

5050
/**
5151
* Create a new {@link AvailabilityStateHealthIndicator} instance.

module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/beans/BeansEndpoint.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
3030
import org.springframework.context.ApplicationContext;
3131
import org.springframework.context.ConfigurableApplicationContext;
32+
import org.springframework.lang.Contract;
3233
import org.springframework.util.StringUtils;
3334

3435
/**
@@ -56,7 +57,7 @@ public BeansEndpoint(ConfigurableApplicationContext context) {
5657

5758
@ReadOperation
5859
public BeansDescriptor beans() {
59-
Map<String, ContextBeansDescriptor> contexts = new HashMap<>();
60+
Map<@Nullable String, ContextBeansDescriptor> contexts = new HashMap<>();
6061
ConfigurableApplicationContext context = this.context;
6162
while (context != null) {
6263
contexts.put(context.getId(), ContextBeansDescriptor.describing(context));
@@ -79,13 +80,13 @@ public BeansDescriptor beans() {
7980
*/
8081
public static final class BeansDescriptor implements OperationResponseBody {
8182

82-
private final Map<String, ContextBeansDescriptor> contexts;
83+
private final Map<@Nullable String, ContextBeansDescriptor> contexts;
8384

84-
private BeansDescriptor(Map<String, ContextBeansDescriptor> contexts) {
85+
private BeansDescriptor(Map<@Nullable String, ContextBeansDescriptor> contexts) {
8586
this.contexts = contexts;
8687
}
8788

88-
public Map<String, ContextBeansDescriptor> getContexts() {
89+
public Map<@Nullable String, ContextBeansDescriptor> getContexts() {
8990
return this.contexts;
9091
}
9192

@@ -113,6 +114,7 @@ public Map<String, BeanDescriptor> getBeans() {
113114
return this.beans;
114115
}
115116

117+
@Contract("!null -> !null")
116118
private static @Nullable ContextBeansDescriptor describing(@Nullable ConfigurableApplicationContext context) {
117119
if (context == null) {
118120
return null;

module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ private boolean isCandidate(BeanDescription beanDesc, BeanPropertyWriter writer,
511511
@Nullable Constructor<?> constructor) {
512512
if (constructor != null) {
513513
Parameter[] parameters = constructor.getParameters();
514-
@Nullable String[] names = PARAMETER_NAME_DISCOVERER.getParameterNames(constructor);
514+
@Nullable String @Nullable [] names = PARAMETER_NAME_DISCOVERER.getParameterNames(constructor);
515515
if (names == null) {
516516
names = new String[parameters.length];
517517
}
@@ -520,7 +520,7 @@ private boolean isCandidate(BeanDescription beanDesc, BeanPropertyWriter writer,
520520
.get(Name.class)
521521
.getValue(MergedAnnotation.VALUE, String.class)
522522
.orElse((names[i] != null) ? names[i] : parameters[i].getName());
523-
if (name.equals(writer.getName())) {
523+
if (name != null && name.equals(writer.getName())) {
524524
return true;
525525
}
526526
}

module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/security/AuthenticationAuditListener.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ else if (event instanceof LogoutSuccessEvent logoutSuccessEvent) {
8989
}
9090

9191
private void onAuthenticationFailureEvent(AbstractAuthenticationFailureEvent event) {
92-
Map<String, Object> data = new LinkedHashMap<>();
92+
Map<String, @Nullable Object> data = new LinkedHashMap<>();
9393
data.put("type", event.getException().getClass().getName());
9494
data.put("message", event.getException().getMessage());
9595
if (event.getAuthentication().getDetails() != null) {
@@ -99,15 +99,15 @@ private void onAuthenticationFailureEvent(AbstractAuthenticationFailureEvent eve
9999
}
100100

101101
private void onAuthenticationSuccessEvent(AuthenticationSuccessEvent event) {
102-
Map<String, Object> data = new LinkedHashMap<>();
102+
Map<String, @Nullable Object> data = new LinkedHashMap<>();
103103
if (event.getAuthentication().getDetails() != null) {
104104
data.put("details", event.getAuthentication().getDetails());
105105
}
106106
publish(new AuditEvent(event.getAuthentication().getName(), AUTHENTICATION_SUCCESS, data));
107107
}
108108

109109
private void onLogoutSuccessEvent(LogoutSuccessEvent event) {
110-
Map<String, Object> data = new LinkedHashMap<>();
110+
Map<String, @Nullable Object> data = new LinkedHashMap<>();
111111
if (event.getAuthentication().getDetails() != null) {
112112
data.put("details", event.getAuthentication().getDetails());
113113
}
@@ -119,7 +119,7 @@ private static final class WebAuditListener {
119119
void process(@Nullable AuthenticationAuditListener listener, AbstractAuthenticationEvent input) {
120120
if (listener != null) {
121121
AuthenticationSwitchUserEvent event = (AuthenticationSwitchUserEvent) input;
122-
Map<String, Object> data = new HashMap<>();
122+
Map<String, @Nullable Object> data = new HashMap<>();
123123
if (event.getAuthentication().getDetails() != null) {
124124
data.put("details", event.getAuthentication().getDetails());
125125
}

module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/security/AuthorizationAuditListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void onApplicationEvent(AuthorizationEvent event) {
5050

5151
private void onAuthorizationDeniedEvent(AuthorizationDeniedEvent<?> event) {
5252
String name = getName(event.getAuthentication());
53-
Map<String, Object> data = new LinkedHashMap<>();
53+
Map<String, @Nullable Object> data = new LinkedHashMap<>();
5454
Object details = getDetails(event.getAuthentication());
5555
if (details != null) {
5656
data.put("details", details);

0 commit comments

Comments
 (0)