Revision: 6860
Author: [email protected]
Date: Wed Nov 11 18:35:07 2009
Log: tr...@6859 was merged into this branch
   Close the socket used by the MessageTransport class if we experience any  
errors.  Included Scott's assertion message improvements from  
http://gwt-code-reviews.appspot.com/100805.
     svn merge --ignore-ancestry -c6859  
https://google-web-toolkit.googlecode.com/svn/trunk/ .


http://code.google.com/p/google-web-toolkit/source/detail?r=6860

Modified:
  /releases/2.0/branch-info.txt
   
/releases/2.0/dev/core/src/com/google/gwt/dev/shell/remoteui/MessageTransport.java
  /releases/2.0/dev/core/src/com/google/gwt/dev/shell/remoteui/RemoteUI.java
   
/releases/2.0/dev/core/test/com/google/gwt/dev/shell/remoteui/MessageTransportTest.java

=======================================
--- /releases/2.0/branch-info.txt       Wed Nov 11 17:18:27 2009
+++ /releases/2.0/branch-info.txt       Wed Nov 11 18:35:07 2009
@@ -583,3 +583,8 @@
      svn merge --ignore-ancestry -r6853:6857 \
        https://google-web-toolkit.googlecode.com/svn/trunk .

+tr...@6859 was merged into this branch
+  Close the socket used by the MessageTransport class if we experience any  
errors.  Included Scott's assertion message improvements from  
http://gwt-code-
+reviews.appspot.com/100805.
+    svn merge --ignore-ancestry -c6859  
https://google-web-toolkit.googlecode.com/svn/trunk/ .
+
=======================================
---  
/releases/2.0/dev/core/src/com/google/gwt/dev/shell/remoteui/MessageTransport.java
       
Tue Nov 10 11:13:04 2009
+++  
/releases/2.0/dev/core/src/com/google/gwt/dev/shell/remoteui/MessageTransport.java
       
Wed Nov 11 18:35:07 2009
@@ -236,20 +236,6 @@
    private final ExecutorService serverRequestExecutor;
    private final PendingRequestMap pendingRequestMap = new  
PendingRequestMap();
    private final TerminationCallback terminationCallback;
-
-  /**
-   * Create a new instance using the given streams and request processor.
-   * Closing either stream will cause the termination of the transport.
-   *
-   * @param inputStream an input stream for reading messages
-   * @param outputStream an output stream for writing messages
-   * @param requestProcessor a callback interface for handling remote  
client
-   *          requests
-   */
-  public MessageTransport(InputStream inputStream, OutputStream  
outputStream,
-      RequestProcessor requestProcessor) {
-    this(inputStream, outputStream, requestProcessor, null);
-  }

    /**
     * Create a new instance using the given streams and request processor.
=======================================
---  
/releases/2.0/dev/core/src/com/google/gwt/dev/shell/remoteui/RemoteUI.java      
 
Tue Nov 10 11:13:04 2009
+++  
/releases/2.0/dev/core/src/com/google/gwt/dev/shell/remoteui/RemoteUI.java      
 
Wed Nov 11 18:35:07 2009
@@ -39,15 +39,15 @@
  public class RemoteUI extends DevModeUI implements
      MessageTransport.TerminationCallback {

-  private final List<ModuleHandle> modules = new ArrayList<ModuleHandle>();
-  private final Object modulesLock = new Object();
-
+  private final int browserChannelPort;
    private final String clientId;
    private final DevModeServiceRequestProcessor devModeRequestProcessor;
+  private final List<ModuleHandle> modules = new ArrayList<ModuleHandle>();
+  private final Object modulesLock = new Object();
+  private final Socket transportSocket;
    private final MessageTransport transport;
    private ViewerServiceClient viewerServiceClient = null;
    private final int webServerPort;
-  private final int browserChannelPort;

    public RemoteUI(String host, int port, String clientId, int  
webServerPort,
        int browserChannelPort) {
@@ -56,12 +56,12 @@
        this.browserChannelPort = browserChannelPort;
        this.webServerPort = webServerPort;

-      Socket socket = new Socket(host, port);
-      socket.setKeepAlive(true);
-      socket.setTcpNoDelay(true);
+      transportSocket = new Socket(host, port);
+      transportSocket.setKeepAlive(true);
+      transportSocket.setTcpNoDelay(true);
        devModeRequestProcessor = new DevModeServiceRequestProcessor(this);
-      transport = new MessageTransport(socket.getInputStream(),
-          socket.getOutputStream(), devModeRequestProcessor, this);
+      transport = new MessageTransport(transportSocket.getInputStream(),
+          transportSocket.getOutputStream(), devModeRequestProcessor,  
this);
      } catch (UnknownHostException e) {
        throw new RuntimeException(e);
      } catch (IOException e) {
@@ -126,9 +126,17 @@
      getTopLogger().log(
          TreeLogger.INFO,
          "Remote UI connection terminated due to exception: "
-            + e.getLocalizedMessage());
+            + e);
      getTopLogger().log(TreeLogger.INFO,
          "Shutting down development mode server.");
+
+    try {
+      // Close the transport socket
+      transportSocket.close();
+    } catch (IOException e1) {
+      // Purposely ignored
+    }
+
      ((DoneCallback) getCallback(DoneEvent.getType())).onDone();
    }

=======================================
---  
/releases/2.0/dev/core/test/com/google/gwt/dev/shell/remoteui/MessageTransportTest.java
  
Mon Nov  9 08:06:34 2009
+++  
/releases/2.0/dev/core/test/com/google/gwt/dev/shell/remoteui/MessageTransportTest.java
  
Wed Nov 11 18:35:07 2009
@@ -112,7 +112,11 @@
      // Set up a transport on the client side
      MessageTransport messageTransport = new MessageTransport(
          network.getClientSocket().getInputStream(),
-        network.getClientSocket().getOutputStream(), requestProcessor);
+        network.getClientSocket().getOutputStream(), requestProcessor,
+        new MessageTransport.TerminationCallback() {
+          public void onTermination(Exception e) {
+          }
+        });

      Message.Request.Builder requestMessageBuilder =  
Message.Request.newBuilder();
       
requestMessageBuilder.setServiceType(Message.Request.ServiceType.DEV_MODE);
@@ -132,7 +136,8 @@
      } catch (TimeoutException te) {
        fail("Should not have timed out");
      } catch (ExecutionException e) {
-      assertTrue(e.getCause() instanceof IllegalStateException);
+      assertTrue("Expected: IllegalStateException, actual:" + e.getCause(),
+          e.getCause() instanceof IllegalStateException);
      } catch (Exception e) {
        fail("Should not have thrown any other exception");
      }
@@ -164,7 +169,7 @@
      // Set up a transport on the client side
      MessageTransport messageTransport = new MessageTransport(
          network.getClientSocket().getInputStream(),
-        network.getClientSocket().getOutputStream(), requestProcessor);
+        network.getClientSocket().getOutputStream(), requestProcessor,  
null);

      // Generate a new request
      DevModeRequest.Builder devModeRequestBuilder =  
DevModeRequest.newBuilder();
@@ -235,7 +240,11 @@
      // Set up a message transport on the client side
      MessageTransport messageTransport = new MessageTransport(
          network.getClientSocket().getInputStream(),
-        network.getClientSocket().getOutputStream(), requestProcessor);
+        network.getClientSocket().getOutputStream(), requestProcessor,
+        new MessageTransport.TerminationCallback() {
+          public void onTermination(Exception e) {
+          }
+        });

      // Generate a new request
      Message.Request.Builder requestMessageBuilder =  
Message.Request.newBuilder();
@@ -272,7 +281,8 @@
        fail("Should not have timed out");
      } catch (ExecutionException e) {
        // This is where we should hit
-      assertTrue(e.getCause() instanceof RequestException);
+      assertTrue("Expected: IllegalStateException, actual:" + e.getCause(),
+          e.getCause() instanceof IllegalStateException);
        RequestException re = (RequestException) e.getCause();
        assertEquals(re.getMessage(), "Unable to process the request.");
      } catch (Exception e) {
@@ -307,7 +317,11 @@
      // Set up a message transport on the client side
      MessageTransport messageTransport = new MessageTransport(
          network.getClientSocket().getInputStream(),
-        network.getClientSocket().getOutputStream(), requestProcessor);
+        network.getClientSocket().getOutputStream(), requestProcessor,
+        new MessageTransport.TerminationCallback() {
+          public void onTermination(Exception e) {
+          }
+        });

      Message.Request.Builder requestMessageBuilder =  
Message.Request.newBuilder();
       
requestMessageBuilder.setServiceType(Message.Request.ServiceType.DEV_MODE);
@@ -324,7 +338,8 @@
        fail("Should not have timed out");
      } catch (ExecutionException e) {
        // This is where we should hit
-      assertTrue(e.getCause() instanceof IllegalStateException);
+      assertTrue("Expected: IllegalStateException, actual:" + e.getCause(),
+          e.getCause() instanceof IllegalStateException);
      } catch (Exception e) {
        fail("Should not have thrown any other exception");
      }
@@ -372,9 +387,12 @@
      };

      // Start up the message transport on the server side
-    MessageTransport messageTransport = new MessageTransport(
-        network.getClientSocket().getInputStream(),
-        network.getClientSocket().getOutputStream(), requestProcessor);
+    new MessageTransport(network.getClientSocket().getInputStream(),
+        network.getClientSocket().getOutputStream(), requestProcessor,
+        new MessageTransport.TerminationCallback() {
+          public void onTermination(Exception e) {
+          }
+        });

      // Send the request from the client to the server
      Message.Builder clientRequestMsgBuilder = Message.newBuilder();
@@ -423,9 +441,12 @@
      };

      // Start up the message transport on the server side
-    MessageTransport messageTransport = new MessageTransport(
-        network.getClientSocket().getInputStream(),
-        network.getClientSocket().getOutputStream(), requestProcessor);
+    new MessageTransport(network.getClientSocket().getInputStream(),
+        network.getClientSocket().getOutputStream(), requestProcessor,
+        new MessageTransport.TerminationCallback() {
+          public void onTermination(Exception e) {
+          }
+        });

      // Send a request to the server
      Message.Request.Builder clientRequestBuilder =  
Message.Request.newBuilder();

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to