This commit is contained in:
Dmitry Isaenko 2020-11-02 16:09:31 +03:00
parent c7e2912045
commit 627013e19c
5 changed files with 16 additions and 6 deletions

View file

@ -17,7 +17,6 @@ public class BotStart {
} }
if (cli.hasOption("c") || cli.hasOption("configuration")){ if (cli.hasOption("c") || cli.hasOption("configuration")){
final String[] arguments = cli.getOptionValues("configuration"); final String[] arguments = cli.getOptionValues("configuration");
for (String a: arguments)
ConnectionsBuilder.buildConnections(arguments); ConnectionsBuilder.buildConnections(arguments);
return; return;
} }

View file

@ -70,7 +70,7 @@ public class ChanConsumer implements Runnable {
parse(); parse();
} }
} catch (InterruptedException e){ } catch (InterruptedException e){
System.out.println("ChanConsumer "+serverName+"/"+channelName+"Interrupted "+e.getMessage()); System.out.println("ChanConsumer "+serverName+"/"+channelName+" Interrupted ");
} }
} }

View file

@ -117,8 +117,10 @@ public class DataProvider implements Runnable {
private void close(){ private void close(){
try { try {
systemConsumerThread.interrupt(); if (systemConsumerThread != null) {
systemConsumerThread.join(); systemConsumerThread.interrupt();
systemConsumerThread.join();
}
StreamProvider.delStream(server); StreamProvider.delStream(server);
ReconnectControl.notify(server); ReconnectControl.notify(server);
} }

View file

@ -1,5 +1,7 @@
package InnaIrcBot; package InnaIrcBot;
import InnaIrcBot.linkstitles.LinksTitleManager;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -17,19 +19,22 @@ public class ReconnectControl {
} }
public static synchronized void notify(String server){ public static synchronized void notify(String server){
if (! serversList.getOrDefault(server, false)) if (! serversList.getOrDefault(server, false)) {
LinksTitleManager.interrupt();
return; return;
}
int count = serversReconnects.get(server); int count = serversReconnects.get(server);
if (count > 5) { if (count > 5) {
serversList.replace(server, false); serversList.replace(server, false);
LinksTitleManager.interrupt();
return; return;
} }
count++; count++;
serversReconnects.put(server, count); serversReconnects.put(server, count);
System.out.println("Main thread \"" + server + "\" removed from observable list after unexpected finish.\n"); System.out.println("Main thread \"" + server + "\" removed from observable list after unexpected finish ("+count+").\n");
ConnectionsBuilder.getConnections().startNewConnection(server); ConnectionsBuilder.getConnections().startNewConnection(server);
} }
} }

View file

@ -15,4 +15,8 @@ public class LinksTitleManager {
} }
return queue; return queue;
} }
public static void interrupt(){
thread.interrupt();
}
} }