Browse Source

Polish

pull/32078/head
Stéphane Nicoll 2 years ago
parent
commit
11c8b22c5a
  1. 39
      spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java
  2. 4
      spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactoryBean.java
  3. 7
      spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java
  4. 5
      spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java

39
spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -736,27 +736,24 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe @@ -736,27 +736,24 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
}
// Not using the Quartz startDelayed method since we explicitly want a daemon
// thread here, not keeping the JVM alive in case of all other threads ending.
Thread schedulerThread = new Thread() {
@Override
public void run() {
try {
TimeUnit.SECONDS.sleep(startupDelay);
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
// simply proceed
}
if (logger.isInfoEnabled()) {
logger.info("Starting Quartz Scheduler now, after delay of " + startupDelay + " seconds");
}
try {
scheduler.start();
}
catch (SchedulerException ex) {
throw new SchedulingException("Could not start Quartz Scheduler after delay", ex);
}
Thread schedulerThread = new Thread(() -> {
try {
TimeUnit.SECONDS.sleep(startupDelay);
}
};
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
// simply proceed
}
if (logger.isInfoEnabled()) {
logger.info("Starting Quartz Scheduler now, after delay of " + startupDelay + " seconds");
}
try {
scheduler.start();
}
catch (SchedulerException ex) {
throw new SchedulingException("Could not start Quartz Scheduler after delay", ex);
}
});
schedulerThread.setName("Quartz Scheduler [" + scheduler.getSchedulerName() + "]");
schedulerThread.setDaemon(true);
schedulerThread.start();

4
spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactoryBean.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,7 +31,7 @@ import org.springframework.lang.Nullable; @@ -31,7 +31,7 @@ import org.springframework.lang.Nullable;
* bean reference. This bean is intended for any kind of usage of FreeMarker
* in application code, e.g. for generating email content. For web views,
* FreeMarkerConfigurer is used to set up a FreeMarkerConfigurationFactory.
*
* <p>
* The simplest way to use this class is to specify just a "templateLoaderPath";
* you do not need any further configuration then. For example, in a web
* application context:

7
spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java

@ -18,6 +18,7 @@ package org.springframework.mail.javamail; @@ -18,6 +18,7 @@ package org.springframework.mail.javamail;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
@ -72,7 +73,7 @@ class JavaMailSenderTests { @@ -72,7 +73,7 @@ class JavaMailSenderTests {
simpleMessage.setTo("you@mail.org");
simpleMessage.setCc("he@mail.org", "she@mail.org");
simpleMessage.setBcc("us@mail.org", "them@mail.org");
Date sentDate = new GregorianCalendar(2004, 1, 1).getTime();
Date sentDate = new GregorianCalendar(2004, Calendar.FEBRUARY, 1).getTime();
simpleMessage.setSentDate(sentDate);
simpleMessage.setSubject("my subject");
simpleMessage.setText("my text");
@ -305,7 +306,7 @@ class JavaMailSenderTests { @@ -305,7 +306,7 @@ class JavaMailSenderTests {
MimeMessage mimeMessage = sender.createMimeMessage();
mimeMessage.setSubject("custom");
mimeMessage.setRecipient(RecipientType.TO, new InternetAddress("you@mail.org"));
mimeMessage.setSentDate(new GregorianCalendar(2005, 3, 1).getTime());
mimeMessage.setSentDate(new GregorianCalendar(2005, Calendar.APRIL, 1).getTime());
sender.send(mimeMessage);
assertThat(sender.transport.getConnectedHost()).isEqualTo("host");
@ -523,7 +524,7 @@ class JavaMailSenderTests { @@ -523,7 +524,7 @@ class JavaMailSenderTests {
throw new MessagingException("No sentDate specified");
}
if (message.getSubject() != null && message.getSubject().contains("custom")) {
assertThat(message.getSentDate()).isEqualTo(new GregorianCalendar(2005, 3, 1).getTime());
assertThat(message.getSentDate()).isEqualTo(new GregorianCalendar(2005, Calendar.APRIL, 1).getTime());
}
this.sentMessages.add(message);
}

5
spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java

@ -391,11 +391,6 @@ class QuartzSupportTests { @@ -391,11 +391,6 @@ class QuartzSupportTests {
try (ClassPathXmlApplicationContext ctx = context("databasePersistence.xml")) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(ctx.getBean(DataSource.class));
assertThat(jdbcTemplate.queryForList("SELECT * FROM qrtz_triggers").isEmpty()).as("No triggers were persisted").isFalse();
/*
Thread.sleep(3000);
assertTrue("DummyJob should have been executed at least once.", DummyJob.count > 0);
*/
}
}

Loading…
Cancel
Save