55import org .jetbrains .annotations .Nullable ;
66
77import java .io .IOException ;
8+ import java .net .ConnectException ;
9+ import java .net .UnknownHostException ;
810import java .util .Optional ;
911import java .util .Random ;
1012import java .util .concurrent .CompletableFuture ;
@@ -129,7 +131,12 @@ public static boolean inSession() {
129131 public static RNGSession createRNGSessionOrNull () {
130132 try {
131133 return new RNGSession (ServerSideRNG .getStartRunToken ());
132- } catch (IOException e ) {
134+ }
135+ catch (UnknownHostException | ConnectException e ){
136+ ServerSideRNG .log (Level .WARN ,"Failed to create new RNGSession: Could not connect to the Server." );
137+ return null ;
138+ }
139+ catch (IOException e ) {
133140 ServerSideRNG .log (Level .WARN ,"Failed to create new RNGSession: " );
134141 e .printStackTrace ();
135142 return null ;
@@ -208,8 +215,6 @@ boolean updateSessionState(){
208215 public void getRngHandlerFromFuture () {
209216 try {
210217 currentRNGHandler = rngHandlerCompletableFuture .get (1L , TimeUnit .SECONDS );
211- currentRNGHandler .activate (handlerIndex ++);
212- currentRNGHandler .log (Level .INFO ,"Successfully updated the current RNGHandler!" );
213218 } catch (InterruptedException | ExecutionException | TimeoutException e ) {
214219 e .printStackTrace ();
215220 }
@@ -222,8 +227,15 @@ public void getRngHandlerFromFuture() {
222227 }
223228 else {
224229 this .log (Level .WARN ,"Failed to update the current RNGHandler!" );
230+ return ;
225231 }
226232 }
233+ else {
234+ currentRNGHandler .activate (handlerIndex ++);
235+ currentRNGHandler .log (Level .INFO ,"Successfully updated the current RNGHandler!" );
236+ }
237+
238+
227239 rngHandlerCompletableFuture = CompletableFuture .supplyAsync (()-> RNGHandler .createRNGHandlerOrNull (runId ));
228240 }
229241 /**
0 commit comments