Moved CONNECT_TIMEOUT to Constants.

This commit is contained in:
Erik C. Thauvin 2019-04-19 22:55:14 -07:00
parent 8e8e530181
commit 72dce163e9
3 changed files with 13 additions and 9 deletions

View file

@ -40,6 +40,11 @@ package net.thauvin.erik.mobibot;
* @since 1.0
*/
public final class Constants {
/**
* The connect/read timeout in ms.
*/
public static final int CONNECT_TIMEOUT = 5000;
/**
* The empty title string.
*/

View file

@ -97,10 +97,6 @@ import java.util.StringTokenizer;
@SuppressWarnings("WeakerAccess")
@Version(properties = "version.properties", className = "ReleaseInfo")
public class Mobibot extends PircBot {
/**
* The connect/read timeout in ms.
*/
public static final int CONNECT_TIMEOUT = 5000;
// The default port.
private static final int DEFAULT_PORT = 6667;
@ -221,8 +217,10 @@ public class Mobibot extends PircBot {
* @param p The bot's properties.
*/
public Mobibot(final String nickname, final String channel, final String logsDirPath, final Properties p) {
System.getProperties().setProperty("sun.net.client.defaultConnectTimeout", String.valueOf(CONNECT_TIMEOUT));
System.getProperties().setProperty("sun.net.client.defaultReadTimeout", String.valueOf(CONNECT_TIMEOUT));
System.getProperties().setProperty("sun.net.client.defaultConnectTimeout",
String.valueOf(Constants.CONNECT_TIMEOUT));
System.getProperties().setProperty("sun.net.client.defaultReadTimeout",
String.valueOf(Constants.CONNECT_TIMEOUT));
setName(nickname);

View file

@ -32,6 +32,7 @@
package net.thauvin.erik.mobibot.modules;
import net.thauvin.erik.mobibot.Constants;
import net.thauvin.erik.mobibot.Mobibot;
import org.apache.commons.net.whois.WhoisClient;
@ -123,9 +124,9 @@ public final class Lookup extends AbstractModule {
final String[] lines;
try {
whoisClient.setDefaultTimeout(Mobibot.CONNECT_TIMEOUT);
whoisClient.setDefaultTimeout(Constants.CONNECT_TIMEOUT);
whoisClient.connect(host);
whoisClient.setSoTimeout(Mobibot.CONNECT_TIMEOUT);
whoisClient.setSoTimeout(Constants.CONNECT_TIMEOUT);
whoisClient.setSoLinger(false, 0);
if (host.equals(WHOIS_HOST)) {