31
31
import java .util .Set ;
32
32
import java .util .function .Function ;
33
33
34
+ import org .jspecify .annotations .Nullable ;
34
35
import org .quartz .CalendarIntervalTrigger ;
35
36
import org .quartz .CronTrigger ;
36
37
import org .quartz .DailyTimeIntervalTrigger ;
55
56
import org .springframework .boot .actuate .endpoint .SanitizingFunction ;
56
57
import org .springframework .boot .actuate .endpoint .annotation .Endpoint ;
57
58
import org .springframework .boot .actuate .endpoint .annotation .ReadOperation ;
59
+ import org .springframework .lang .Contract ;
58
60
import org .springframework .util .Assert ;
59
61
60
62
/**
@@ -137,7 +139,7 @@ public QuartzGroupsDescriptor quartzTriggerGroups() throws SchedulerException {
137
139
* @return a summary of the jobs in the given {@code group}
138
140
* @throws SchedulerException if retrieving the information from the scheduler failed
139
141
*/
140
- public QuartzJobGroupSummaryDescriptor quartzJobGroupSummary (String group ) throws SchedulerException {
142
+ public @ Nullable QuartzJobGroupSummaryDescriptor quartzJobGroupSummary (String group ) throws SchedulerException {
141
143
List <JobDetail > jobs = findJobsByGroup (group );
142
144
if (jobs .isEmpty () && !this .scheduler .getJobGroupNames ().contains (group )) {
143
145
return null ;
@@ -165,7 +167,8 @@ private List<JobDetail> findJobsByGroup(String group) throws SchedulerException
165
167
* @return a summary of the triggers in the given {@code group}
166
168
* @throws SchedulerException if retrieving the information from the scheduler failed
167
169
*/
168
- public QuartzTriggerGroupSummaryDescriptor quartzTriggerGroupSummary (String group ) throws SchedulerException {
170
+ public @ Nullable QuartzTriggerGroupSummaryDescriptor quartzTriggerGroupSummary (String group )
171
+ throws SchedulerException {
169
172
List <Trigger > triggers = findTriggersByGroup (group );
170
173
if (triggers .isEmpty () && !this .scheduler .getTriggerGroupNames ().contains (group )) {
171
174
return null ;
@@ -199,7 +202,7 @@ private List<Trigger> findTriggersByGroup(String group) throws SchedulerExceptio
199
202
* @return the details of the job or {@code null} if such job does not exist
200
203
* @throws SchedulerException if retrieving the information from the scheduler failed
201
204
*/
202
- public QuartzJobDetailsDescriptor quartzJob (String groupName , String jobName , boolean showUnsanitized )
205
+ public @ Nullable QuartzJobDetailsDescriptor quartzJob (String groupName , String jobName , boolean showUnsanitized )
203
206
throws SchedulerException {
204
207
JobKey jobKey = JobKey .jobKey (jobName , groupName );
205
208
JobDetail jobDetail = this .scheduler .getJobDetail (jobKey );
@@ -219,11 +222,12 @@ public QuartzJobDetailsDescriptor quartzJob(String groupName, String jobName, bo
219
222
* exist
220
223
* @throws SchedulerException if there is an error triggering the job
221
224
*/
222
- public QuartzJobTriggerDescriptor triggerQuartzJob (String groupName , String jobName ) throws SchedulerException {
225
+ public @ Nullable QuartzJobTriggerDescriptor triggerQuartzJob (String groupName , String jobName )
226
+ throws SchedulerException {
223
227
return triggerQuartzJob (JobKey .jobKey (jobName , groupName ));
224
228
}
225
229
226
- private QuartzJobTriggerDescriptor triggerQuartzJob (JobKey jobKey ) throws SchedulerException {
230
+ private @ Nullable QuartzJobTriggerDescriptor triggerQuartzJob (JobKey jobKey ) throws SchedulerException {
227
231
JobDetail jobDetail = this .scheduler .getJobDetail (jobKey );
228
232
if (jobDetail == null ) {
229
233
return null ;
@@ -255,7 +259,7 @@ private static List<Map<String, Object>> extractTriggersSummary(List<? extends T
255
259
* @return the details of the trigger or {@code null} if such trigger does not exist
256
260
* @throws SchedulerException if retrieving the information from the scheduler failed
257
261
*/
258
- Map <String , Object > quartzTrigger (String groupName , String triggerName , boolean showUnsanitized )
262
+ @ Nullable Map <String , Object > quartzTrigger (String groupName , String triggerName , boolean showUnsanitized )
259
263
throws SchedulerException {
260
264
TriggerKey triggerKey = TriggerKey .triggerKey (triggerName , groupName );
261
265
Trigger trigger = this .scheduler .getTrigger (triggerKey );
@@ -272,12 +276,13 @@ private static Duration getIntervalDuration(long amount, IntervalUnit unit) {
272
276
return temporalUnit (unit ).getDuration ().multipliedBy (amount );
273
277
}
274
278
275
- private static LocalTime getLocalTime (TimeOfDay timeOfDay ) {
279
+ private static @ Nullable LocalTime getLocalTime (@ Nullable TimeOfDay timeOfDay ) {
276
280
return (timeOfDay != null ) ? LocalTime .of (timeOfDay .getHour (), timeOfDay .getMinute (), timeOfDay .getSecond ())
277
281
: null ;
278
282
}
279
283
280
- private Map <String , Object > sanitizeJobDataMap (JobDataMap dataMap , boolean showUnsanitized ) {
284
+ @ Contract ("!null, _ -> !null" )
285
+ private @ Nullable Map <String , Object > sanitizeJobDataMap (@ Nullable JobDataMap dataMap , boolean showUnsanitized ) {
281
286
if (dataMap == null ) {
282
287
return null ;
283
288
}
@@ -286,7 +291,7 @@ private Map<String, Object> sanitizeJobDataMap(JobDataMap dataMap, boolean showU
286
291
return map ;
287
292
}
288
293
289
- private Object getSanitizedValue (boolean showUnsanitized , String key , Object value ) {
294
+ private @ Nullable Object getSanitizedValue (boolean showUnsanitized , String key , @ Nullable Object value ) {
290
295
SanitizableData data = new SanitizableData (null , key , value );
291
296
return this .sanitizer .sanitize (data , showUnsanitized );
292
297
}
@@ -669,7 +674,8 @@ public Map<String, Object> buildSummary(boolean addTriggerSpecificSummary) {
669
674
* @param sanitizedDataMap a sanitized data map or {@code null}
670
675
* @return all properties of the trigger
671
676
*/
672
- public Map <String , Object > buildDetails (TriggerState triggerState , Map <String , Object > sanitizedDataMap ) {
677
+ public Map <String , Object > buildDetails (TriggerState triggerState ,
678
+ @ Nullable Map <String , Object > sanitizedDataMap ) {
673
679
Map <String , Object > details = new LinkedHashMap <>();
674
680
details .put ("group" , this .trigger .getKey ().getGroup ());
675
681
details .put ("name" , this .trigger .getKey ().getName ());
@@ -697,7 +703,7 @@ public Map<String, Object> buildDetails(TriggerState triggerState, Map<String, O
697
703
*/
698
704
protected abstract void appendDetails (Map <String , Object > content );
699
705
700
- protected void putIfNoNull (Map <String , Object > content , String key , Object value ) {
706
+ protected void putIfNoNull (Map <String , Object > content , String key , @ Nullable Object value ) {
701
707
if (value != null ) {
702
708
content .put (key , value );
703
709
}
0 commit comments