@@ -156,7 +156,7 @@ public void setConfig(Configuration config, Stage primaryStage,
156
156
@ Override
157
157
protected Void call () throws Exception {
158
158
System .out .println ("Waiting for normal state via asyncDebugView" );
159
- asyncDebugView ().get (); // Wait for the async operation to complete
159
+ asyncDebugView ().get (); // Wait for the async operation to complete
160
160
waitForNormalState ();
161
161
System .out .println ("before update" );
162
162
removeOldJars (config );
@@ -168,27 +168,42 @@ protected Void call() throws Exception {
168
168
169
169
}
170
170
171
- public Future <String > asyncDebugView () throws InterruptedException {
171
+ public Future <String > asyncDebugView () {
172
172
CompletableFuture <String > completableFuture = new CompletableFuture <>();
173
173
Executors .newCachedThreadPool ().submit (() -> {
174
- System .out .println ("asyncDebugView futuer start!!!!!! !" );
174
+ System .out .println ("asyncDebugView future start!" );
175
175
System .out .println ("StartupState = " + startupState );
176
- int counter = 0 ;
177
- while (startupState == App .state .WAIT || startupState == App .state .DEBUG ) {
176
+
177
+ // Duration to wait (e.g., 3 seconds)
178
+ long waitDuration = 3000 ; // milliseconds
179
+ long startTime = System .currentTimeMillis ();
180
+
181
+ // Check for the DEBUG state every 100ms
182
+ while (System .currentTimeMillis () - startTime < waitDuration ) {
183
+ if (startupState == App .state .DEBUG ) {
184
+ System .out .println ("DEBUG mode activated, keeping state as DEBUG" );
185
+ completableFuture .complete ("Debug Mode" );
186
+ return "Debug Mode" ; // Return String indicating the debug mode
187
+ }
178
188
try {
179
- if (counter == 500 && startupState != App .state .DEBUG ) {
180
- startupState = App .state .NORMAL ;
181
- }
182
- Thread .sleep (5 );
183
- counter ++;
184
- } catch (InterruptedException ex ) {
185
- // On purpose
189
+ Thread .sleep (100 );
190
+ } catch (InterruptedException e ) {
191
+ Thread .currentThread ().interrupt ();
192
+ completableFuture .completeExceptionally (e );
193
+ return "Interrupted" ; // Return String indicating an interruption
186
194
}
187
195
}
188
- completableFuture .complete ("Hello" );
189
- return null ;
196
+
197
+ // If DEBUG mode not activated within timeout, set to NORMAL
198
+ if (startupState != App .state .DEBUG ) {
199
+ System .out .println ("Timeout reached without DEBUG mode, setting state to NORMAL" );
200
+ startupState = App .state .NORMAL ;
201
+ }
202
+
203
+ completableFuture .complete ("Normal State" );
204
+ return "Normal State" ; // Return String indicating normal state
190
205
});
191
-
206
+
192
207
System .out .println ("Return future" );
193
208
return completableFuture ;
194
209
}
@@ -209,7 +224,7 @@ void update() {
209
224
Task <Void > doUpdate = new Task <>() {
210
225
@ Override
211
226
protected Void call () throws Exception {
212
- //asyncDebugView().get();
227
+ // asyncDebugView().get();
213
228
if (!config .requiresUpdate ()) {
214
229
if (!daemonDirExists ()) {
215
230
extractDaemon ();
@@ -535,7 +550,7 @@ public void launchApp() {
535
550
stage .hide ();
536
551
});
537
552
}
538
-
553
+
539
554
private void setupInjectable () {
540
555
inject = new Injectable () {
541
556
@ InjectSource
0 commit comments