2014-01-15 168 views
0

我在Eclipse Juno上使用GWT 2.5.1和Ext GWT v2.2.4運行GWT應用程序。 Java 6(32位),我不能改變任何這一點。由於內部無限循環,GWT應用程序凍結

我最近把這個應用程序交給了另一臺機器,它工作正常。啓動應用程序(運行> GWT應用程序)後,我繼續登錄到我的應用程序,我的代碼正常執行,但然後我的應用程序凍結。我調試,發現應用進入無限循環在此GWT內部方法(即,在com.google.gwt.dev.shell.BrowserChannelServer類):

public void reactToMessages(SessionHandlerServer handler) { 
    do { 
     try { 
     getStreamToOtherSide().flush(); 
     MessageType messageType = Message.readMessageType(
      getStreamFromOtherSide()); 
     switch (messageType) { 
      case FREE_VALUE: 
      final FreeMessage freeMsg = FreeMessage.receive(this); 
      handler.freeValue(this, freeMsg.getIds()); 
      break; 
      case INVOKE: //<<<< Keeps getting into this block 
      InvokeOnServerMessage imsg = InvokeOnServerMessage.receive(this); 
      ExceptionOrReturnValue result = handler.invoke(this, imsg.getThis(), 
       imsg.getMethodDispatchId(), imsg.getArgs()); 
      sendFreedValues(); 
      ReturnMessage.send(this, result); 
      break; 
      case INVOKE_SPECIAL: 
      handleInvokeSpecial(handler); 
      break; 
      case QUIT: 
      return; 
      default: 
      throw new RemoteDeathError(new BrowserChannelException(
       "Invalid message type " + messageType)); 
     } 
     } catch (IOException e) { 
     throw new RemoteDeathError(e); 
     } catch (BrowserChannelException e) { 
     throw new RemoteDeathError(e); 
     } 
    } while (true); 
} 

messageType總是INVOKE並且由於當條件爲,循環永遠不會結束。所以執行是停留在這個堆棧:

Daemon Thread [Code server for av.mymodule from Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0 on http://127.0.0.1:8889/mymodule.html?gwt.codesvr=127.0.0.1:9997 @ tsb2t8vtLUT/vrj#] (Suspended) 
      BrowserChannelServer.reactToMessages(BrowserChannelServer$SessionHandlerServer) line: 292  
      BrowserChannelServer.processConnection() line: 547 
      BrowserChannelServer.run() line: 364 
      Thread.run() line: 662 

我清理項目,刪除緩存文件,.tmp文件,重新編譯了無數次,試過舊版本2.4.0,但我不能嘗試2.6,因爲我會需要目前無法安裝的java 7。我嘗試過Chrome和Firefox,結果相同。經過一番搜索之後,我發現了一些建議,我不應該放大使用瀏覽器,但是,我沒有這樣做。

請問有什麼問題?

回答

0

我覺得你的條件應該是動態變量而不是使用真正。你應該跳出做while循環。如果不是,你的執行可能會疊加。

public class TestDoWhile { 
private static TestDoWhile test; 

public static void main(final String[] args) { 
    test = new TestDoWhile(); 
    test.invokeMethod(2); 
    test.invokeMethod(1); 
} 
public final void invokeMethod(final int testCase) { 
    do { 
     switch (testCase) { 
     case 1: 
      System.out.println("Invoke"); 
      break; 
     case 2: 
      System.out.println("Please , let me quit !"); 
      return; 
     default: 
      return; 
     } 
    } while (true); 
} 
} 

我的java程序的結果是什麼?這可能會疊加。我無法想象你的這兩種方法 sendFreedValues(); ReturnMessage.send(this,result);

因此,添加回報,而不是突破。對你有一些幫助。

+0

正如我所提到的,這是一個內部的GWT代碼。我無法修改它。如果行爲不當,那麼有些事情是非常錯誤的。這可能是一個我非常懷疑的GWT錯誤,但即使如此,只有GWT團隊才能解決它,因爲我對GWT內部知識一無所知。 –

+0

@MuhammadGelbana我很抱歉!如果是這樣,你應該複製它的源代碼並創建自定義小部件或類,然後再次測試它。有時GWT會給我一些錯誤,還有一些不足之處。我不知道GWT 2.6。 – Cataclysm

1

問題是分機GWT 2.2.4不與GWT 2.5.1兼容,但它是兼容GWT 2.5.0

因此,使用GWT 2.5.0代替,解決了這個問題。

+0

是的,感謝有用的知識。我使用GWT 2.5.1。 (版本.1)被擊中你:) – Cataclysm