Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 354368 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/rwt/internal/lifecycle/RWTLifeCycle.java (-2 / +12 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2011 Innoopract Informationssysteme GmbH and others.
2
 * Copyright (c) 2002, 2012 Innoopract Informationssysteme GmbH and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 33-38 Link Here
33
33
34
  private static final String CURRENT_PHASE = RWTLifeCycle.class.getName() + ".currentPhase";
34
  private static final String CURRENT_PHASE = RWTLifeCycle.class.getName() + ".currentPhase";
35
  private static final String PHASE_ORDER = RWTLifeCycle.class.getName() + ".phaseOrder";
35
  private static final String PHASE_ORDER = RWTLifeCycle.class.getName() + ".phaseOrder";
36
  private static final String UI_THREAD_WAITING_FOR_THE_END
37
    = UIThreadController.class.getName() + "#UIThreadWaitingForTheEnd";
36
  private static final String UI_THREAD_THROWABLE
38
  private static final String UI_THREAD_THROWABLE
37
    = UIThreadController.class.getName() + "#UIThreadThrowable";
39
    = UIThreadController.class.getName() + "#UIThreadThrowable";
38
  private static final String REQUEST_THREAD_RUNNABLE
40
  private static final String REQUEST_THREAD_RUNNABLE
Lines 190-196 Link Here
190
      }
192
      }
191
    } else {
193
    } else {
192
      uiThread.setServiceContext( context );
194
      uiThread.setServiceContext( context );
193
      uiThread.switchThread();
195
      // See bug 354368
196
      if( !Boolean.TRUE.equals( session.getAttribute( UI_THREAD_WAITING_FOR_THE_END ) ) ) {
197
        uiThread.switchThread();
198
      }
194
    }
199
    }
195
    // TODO [rh] consider moving this to UIThreadController#run
200
    // TODO [rh] consider moving this to UIThreadController#run
196
    if( !uiThread.getThread().isAlive() ) {
201
    if( !uiThread.getThread().isAlive() ) {
Lines 289-294 Link Here
289
            IServiceStore serviceStore = ContextProvider.getServiceStore();
294
            IServiceStore serviceStore = ContextProvider.getServiceStore();
290
            serviceStore.setAttribute( UI_THREAD_THROWABLE, thr );
295
            serviceStore.setAttribute( UI_THREAD_THROWABLE, thr );
291
          }
296
          }
297
          // We have to prevent the ui thread from waking up at that point, otherwise
298
          // processShutdown would never be executed and session store would not be cleared.
299
          // See bug 354368
300
          ISessionStore sessionStore = ContextProvider.getSessionStore();
301
          sessionStore.setAttribute( UI_THREAD_WAITING_FOR_THE_END, Boolean.TRUE );
292
          // In any case: wait for the thread to be terminated by session timeout
302
          // In any case: wait for the thread to be terminated by session timeout
293
          uiThread.switchThread();
303
          uiThread.switchThread();
294
        }
304
        }
(-)src/org/eclipse/rwt/internal/lifecycle/RWTLifeCycle2_Test.java (+59 lines)
Lines 159-164 Link Here
159
    }
159
    }
160
  }
160
  }
161
161
162
  public static final class TestClearSessionStoreOnSessionRestartEntryPoint implements IEntryPoint {
163
    public int createUI() {
164
      createUIEntered = true;
165
      try {
166
        Display display = new Display();
167
        Shell shell = new Shell( display );
168
        shell.setSize( 100, 100 );
169
        shell.layout();
170
        shell.open();
171
        while( !shell.isDisposed() ) {
172
          if( !display.readAndDispatch() ) {
173
            display.sleep();
174
          }
175
        }
176
        return 0;
177
      } finally {
178
        createUIExited = true;
179
      }
180
    }
181
  }
182
162
  public static final class TestSessionInvalidateWithDisposeInFinallyEntryPoint
183
  public static final class TestSessionInvalidateWithDisposeInFinallyEntryPoint
163
    implements IEntryPoint
184
    implements IEntryPoint
164
  {
185
  {
Lines 288-293 Link Here
288
    assertEquals( 0, eventLog.size() );
309
    assertEquals( 0, eventLog.size() );
289
  }
310
  }
290
311
312
  /*
313
   * 354368: Occasional exception on refresh (F5)
314
   * https://bugs.eclipse.org/bugs/show_bug.cgi?id=354368
315
   */
316
  public void testClearSessionStoreOnSessionRestart() throws Exception {
317
    TestRequest request;
318
    Class<? extends IEntryPoint> entryPoint = TestClearSessionStoreOnSessionRestartEntryPoint.class;
319
    RWTFactory.getEntryPointManager().registerByName( EntryPointUtil.DEFAULT, entryPoint );
320
    // send initial request - response is index.html
321
    request = newRequest();
322
    request.setParameter( RequestParams.STARTUP, "default" );
323
    runRWTDelegate( request );
324
    assertTrue( createUIEntered );
325
    assertFalse( createUIExited );
326
    // send 'application startup' request - response is protocol message to create
327
    // client-side representation of what was created in IEntryPoint#createUI
328
    request = newRequest();
329
    request.setParameter( RequestParams.UIROOT, "w1" );
330
    runRWTDelegate( request );
331
    assertTrue( createUIEntered );
332
    assertFalse( createUIExited );
333
    // send a request that closes the main shell
334
    request = newRequest();
335
    request.setParameter( RequestParams.UIROOT, "w1" );
336
    request.setParameter( "org.eclipse.swt.widgets.Shell_close", "w2" );
337
    runRWTDelegate( request );
338
    assertTrue( createUIExited );
339
    // send a request after the createUI has been exited
340
    request = newRequest();
341
    request.setParameter( RequestParams.UIROOT, "w1" );
342
    runRWTDelegate( request );
343
    // send 'restart' request
344
    request = newRequest();
345
    request.setParameter( RequestParams.STARTUP, "default" );
346
    runRWTDelegate( request );
347
    // ensures that no exceptions has been thrown
348
  }
349
291
  private static TestResponse runRWTDelegate( final HttpServletRequest request )
350
  private static TestResponse runRWTDelegate( final HttpServletRequest request )
292
    throws Exception
351
    throws Exception
293
  {
352
  {

Return to bug 354368