harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r585945 - in /harmony/enhanced/classlib/trunk/modules/nio/src: main/java/common/org/apache/harmony/nio/internal/ test/java/common/org/apache/harmony/nio/tests/java/nio/channels/
Date Thu, 18 Oct 2007 12:33:19 GMT
Author: tellison
Date: Thu Oct 18 05:33:17 2007
New Revision: 585945

URL: http://svn.apache.org/viewvc?rev=585945&view=rev
Log:
Fix for HARMONY-4961 (SocketChannel.socket().getLocalPort() returns -1 from ServerSocketChannel)

Modified:
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
    harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java?rev=585945&r1=585944&r2=585945&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/ServerSocketChannelImpl.java
Thu Oct 18 05:33:17 2007
@@ -264,6 +264,7 @@
                 synchronized (this) {
                     super.implAccept(aSocket);
                     sockChannel.setConnected();
+                    sockChannel.setBound(true);
                 }
                 SecurityManager sm = System.getSecurityManager();
                 if (sm != null) {

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java?rev=585945&r1=585944&r2=585945&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
Thu Oct 18 05:33:17 2007
@@ -121,7 +121,7 @@
     int status = SOCKET_STATUS_UNINIT;
 
     // whether the socket is bound
-    boolean isBound = false;
+    volatile boolean isBound = false;
 
     private final Object readLock = new Object();
 
@@ -226,6 +226,10 @@
      */
     synchronized void setConnected() {
         status = SOCKET_STATUS_CONNECTED;
+    }
+
+    void setBound(boolean flag) {
+        isBound = flag;
     }
 
     /*

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java?rev=585945&r1=585944&r2=585945&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
Thu Oct 18 05:33:17 2007
@@ -389,17 +389,17 @@
         assertEquals(s.getLocalAddress().getHostAddress(), "0.0.0.0");
         // RI fails here. RI returns 0 while spec says unbound socket should
         // return -1.
-        assertEquals(s.getLocalPort(), -1);
+        assertEquals(-1, s.getLocalPort());
         assertFalse(s.getReuseAddress());
         assertNull(s.getLocalSocketAddress());
 
         // not connected
-        assertEquals(s.getPort(), 0);
+        assertEquals(0, s.getPort());
         assertTrue(s.getReceiveBufferSize() >= 8192);
         assertNull(s.getRemoteSocketAddress());
         assertTrue(s.getSendBufferSize() >= 8192);
-        assertEquals(s.getSoTimeout(), 0);
-        assertEquals(s.getTrafficClass(), 0);
+        assertEquals(0, s.getSoTimeout());
+        assertEquals(0, s.getTrafficClass());
 
     }
 
@@ -431,8 +431,8 @@
         assertEquals(s.getRemoteSocketAddress(), (SocketAddress) address);
         // assertFalse(s.getReuseAddress());
         assertTrue(s.getSendBufferSize() >= 8192);
-        assertEquals(s.getSoTimeout(), 0);
-        assertEquals(s.getTrafficClass(), 0);
+        assertEquals(0, s.getSoTimeout());
+        assertEquals(0, s.getTrafficClass());
     }
 
     private void assertSocketAction_Block_BeforeConnect(Socket s)



Mime
View raw message