to get rid of "magic" time constants
This commit is contained in:
committed by
Juergen Hoeller
parent
ed7684d2b2
commit
407ecf7334
@@ -20,6 +20,7 @@ import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.quartz.Scheduler;
|
||||
@@ -697,7 +698,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(startupDelay * 1000);
|
||||
Thread.sleep(TimeUnit.SECONDS.toMillis(startupDelay));
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.jdbc.support;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -108,7 +109,7 @@ public class DatabaseStartupValidator implements InitializingBean {
|
||||
try {
|
||||
boolean validated = false;
|
||||
long beginTime = System.currentTimeMillis();
|
||||
long deadLine = beginTime + this.timeout * 1000;
|
||||
long deadLine = beginTime + TimeUnit.SECONDS.toMillis(this.timeout);
|
||||
SQLException latestEx = null;
|
||||
|
||||
while (!validated && System.currentTimeMillis() < deadLine) {
|
||||
@@ -139,7 +140,7 @@ public class DatabaseStartupValidator implements InitializingBean {
|
||||
}
|
||||
|
||||
if (!validated) {
|
||||
Thread.sleep(this.interval * 1000);
|
||||
Thread.sleep(TimeUnit.SECONDS.toMillis(this.interval));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +149,7 @@ public class DatabaseStartupValidator implements InitializingBean {
|
||||
"Database has not started up within " + this.timeout + " seconds", latestEx);
|
||||
}
|
||||
|
||||
float duration = (System.currentTimeMillis() - beginTime) / 1000;
|
||||
float duration = (System.currentTimeMillis() - beginTime)*1f / 1000;
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Database startup detected after " + duration + " seconds");
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -87,7 +88,7 @@ public class DefaultStompSession implements ConnectionHandlingStompSession {
|
||||
@Nullable
|
||||
private TaskScheduler taskScheduler;
|
||||
|
||||
private long receiptTimeLimit = 15 * 1000;
|
||||
private long receiptTimeLimit = TimeUnit.SECONDS.toMillis(15);
|
||||
|
||||
private volatile boolean autoReceiptEnabled;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.messaging.simp.stomp;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.converter.MessageConverter;
|
||||
@@ -48,7 +49,7 @@ public abstract class StompClientSupport {
|
||||
|
||||
private long[] defaultHeartbeat = new long[] {10000, 10000};
|
||||
|
||||
private long receiptTimeLimit = 15 * 1000;
|
||||
private long receiptTimeLimit = TimeUnit.SECONDS.toMillis(15);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.messaging.simp.user;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -56,7 +57,7 @@ public class UserRegistryMessageHandler implements MessageHandler, ApplicationLi
|
||||
@Nullable
|
||||
private volatile ScheduledFuture<?> scheduledFuture;
|
||||
|
||||
private long registryExpirationPeriod = 20 * 1000;
|
||||
private long registryExpirationPeriod = TimeUnit.SECONDS.toMillis(20);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -75,7 +75,7 @@ public class WebSocketMessageBrokerStats {
|
||||
@Nullable
|
||||
private ScheduledFuture<?> loggingTask;
|
||||
|
||||
private long loggingPeriod = 30 * 60 * 1000;
|
||||
private long loggingPeriod = TimeUnit.MINUTES.toMillis(30);
|
||||
|
||||
|
||||
public void setSubProtocolWebSocketHandler(SubProtocolWebSocketHandler webSocketHandler) {
|
||||
@@ -114,7 +114,7 @@ public class WebSocketMessageBrokerStats {
|
||||
|
||||
public void setSockJsTaskScheduler(ThreadPoolTaskScheduler sockJsTaskScheduler) {
|
||||
this.sockJsTaskScheduler = sockJsTaskScheduler.getScheduledThreadPoolExecutor();
|
||||
this.loggingTask = initLoggingTask(60 * 1000);
|
||||
this.loggingTask = initLoggingTask(TimeUnit.MINUTES.toMillis(1));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -87,9 +87,9 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
|
||||
|
||||
private boolean sessionCookieNeeded = true;
|
||||
|
||||
private long heartbeatTime = 25 * 1000;
|
||||
private long heartbeatTime = TimeUnit.SECONDS.toMillis(25);
|
||||
|
||||
private long disconnectDelay = 5 * 1000;
|
||||
private long disconnectDelay = TimeUnit.SECONDS.toMillis(5 );
|
||||
|
||||
private int httpMessageCacheSize = 100;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user