3131import java .util .Set ;
3232import java .util .function .Function ;
3333
34+ import org .jspecify .annotations .Nullable ;
3435import org .quartz .CalendarIntervalTrigger ;
3536import org .quartz .CronTrigger ;
3637import org .quartz .DailyTimeIntervalTrigger ;
5556import org .springframework .boot .actuate .endpoint .SanitizingFunction ;
5657import org .springframework .boot .actuate .endpoint .annotation .Endpoint ;
5758import org .springframework .boot .actuate .endpoint .annotation .ReadOperation ;
59+ import org .springframework .lang .Contract ;
5860import org .springframework .util .Assert ;
5961
6062/**
@@ -137,7 +139,7 @@ public QuartzGroupsDescriptor quartzTriggerGroups() throws SchedulerException {
137139 * @return a summary of the jobs in the given {@code group}
138140 * @throws SchedulerException if retrieving the information from the scheduler failed
139141 */
140- public QuartzJobGroupSummaryDescriptor quartzJobGroupSummary (String group ) throws SchedulerException {
142+ public @ Nullable QuartzJobGroupSummaryDescriptor quartzJobGroupSummary (String group ) throws SchedulerException {
141143 List <JobDetail > jobs = findJobsByGroup (group );
142144 if (jobs .isEmpty () && !this .scheduler .getJobGroupNames ().contains (group )) {
143145 return null ;
@@ -165,7 +167,8 @@ private List<JobDetail> findJobsByGroup(String group) throws SchedulerException
165167 * @return a summary of the triggers in the given {@code group}
166168 * @throws SchedulerException if retrieving the information from the scheduler failed
167169 */
168- public QuartzTriggerGroupSummaryDescriptor quartzTriggerGroupSummary (String group ) throws SchedulerException {
170+ public @ Nullable QuartzTriggerGroupSummaryDescriptor quartzTriggerGroupSummary (String group )
171+ throws SchedulerException {
169172 List <Trigger > triggers = findTriggersByGroup (group );
170173 if (triggers .isEmpty () && !this .scheduler .getTriggerGroupNames ().contains (group )) {
171174 return null ;
@@ -199,7 +202,7 @@ private List<Trigger> findTriggersByGroup(String group) throws SchedulerExceptio
199202 * @return the details of the job or {@code null} if such job does not exist
200203 * @throws SchedulerException if retrieving the information from the scheduler failed
201204 */
202- public QuartzJobDetailsDescriptor quartzJob (String groupName , String jobName , boolean showUnsanitized )
205+ public @ Nullable QuartzJobDetailsDescriptor quartzJob (String groupName , String jobName , boolean showUnsanitized )
203206 throws SchedulerException {
204207 JobKey jobKey = JobKey .jobKey (jobName , groupName );
205208 JobDetail jobDetail = this .scheduler .getJobDetail (jobKey );
@@ -219,11 +222,12 @@ public QuartzJobDetailsDescriptor quartzJob(String groupName, String jobName, bo
219222 * exist
220223 * @throws SchedulerException if there is an error triggering the job
221224 */
222- public QuartzJobTriggerDescriptor triggerQuartzJob (String groupName , String jobName ) throws SchedulerException {
225+ public @ Nullable QuartzJobTriggerDescriptor triggerQuartzJob (String groupName , String jobName )
226+ throws SchedulerException {
223227 return triggerQuartzJob (JobKey .jobKey (jobName , groupName ));
224228 }
225229
226- private QuartzJobTriggerDescriptor triggerQuartzJob (JobKey jobKey ) throws SchedulerException {
230+ private @ Nullable QuartzJobTriggerDescriptor triggerQuartzJob (JobKey jobKey ) throws SchedulerException {
227231 JobDetail jobDetail = this .scheduler .getJobDetail (jobKey );
228232 if (jobDetail == null ) {
229233 return null ;
@@ -255,7 +259,7 @@ private static List<Map<String, Object>> extractTriggersSummary(List<? extends T
255259 * @return the details of the trigger or {@code null} if such trigger does not exist
256260 * @throws SchedulerException if retrieving the information from the scheduler failed
257261 */
258- Map <String , Object > quartzTrigger (String groupName , String triggerName , boolean showUnsanitized )
262+ @ Nullable Map <String , Object > quartzTrigger (String groupName , String triggerName , boolean showUnsanitized )
259263 throws SchedulerException {
260264 TriggerKey triggerKey = TriggerKey .triggerKey (triggerName , groupName );
261265 Trigger trigger = this .scheduler .getTrigger (triggerKey );
@@ -272,12 +276,13 @@ private static Duration getIntervalDuration(long amount, IntervalUnit unit) {
272276 return temporalUnit (unit ).getDuration ().multipliedBy (amount );
273277 }
274278
275- private static LocalTime getLocalTime (TimeOfDay timeOfDay ) {
279+ private static @ Nullable LocalTime getLocalTime (@ Nullable TimeOfDay timeOfDay ) {
276280 return (timeOfDay != null ) ? LocalTime .of (timeOfDay .getHour (), timeOfDay .getMinute (), timeOfDay .getSecond ())
277281 : null ;
278282 }
279283
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 ) {
281286 if (dataMap == null ) {
282287 return null ;
283288 }
@@ -286,7 +291,7 @@ private Map<String, Object> sanitizeJobDataMap(JobDataMap dataMap, boolean showU
286291 return map ;
287292 }
288293
289- private Object getSanitizedValue (boolean showUnsanitized , String key , Object value ) {
294+ private @ Nullable Object getSanitizedValue (boolean showUnsanitized , String key , @ Nullable Object value ) {
290295 SanitizableData data = new SanitizableData (null , key , value );
291296 return this .sanitizer .sanitize (data , showUnsanitized );
292297 }
@@ -669,7 +674,8 @@ public Map<String, Object> buildSummary(boolean addTriggerSpecificSummary) {
669674 * @param sanitizedDataMap a sanitized data map or {@code null}
670675 * @return all properties of the trigger
671676 */
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 ) {
673679 Map <String , Object > details = new LinkedHashMap <>();
674680 details .put ("group" , this .trigger .getKey ().getGroup ());
675681 details .put ("name" , this .trigger .getKey ().getName ());
@@ -697,7 +703,7 @@ public Map<String, Object> buildDetails(TriggerState triggerState, Map<String, O
697703 */
698704 protected abstract void appendDetails (Map <String , Object > content );
699705
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 ) {
701707 if (value != null ) {
702708 content .put (key , value );
703709 }
0 commit comments