harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Regis <xu.re...@gmail.com>
Subject Re: [general] Code Freeze for Milestone 5.0M14 and 6.0M2
Date Thu, 20 May 2010 08:00:09 GMT
On 2010-05-19 20:45, Catherine Hope wrote:
> I also see these 2 tests failing in the same way.  It seems to be caused by
> Regis' commit 944119 "SocketChannelImpl.SocketAdapter's remote address
> should be updated after channel connected" on 14/05/2010.  It could be that
> the tests are invalid though - the first one is checking that the
> SocketAddress returned by getRemoteAddress() is a different object to the
> one that was passed to connect(), though as SocketAddress is immutable would
> this cause a problem?
>

The test case expect behaviors to be exactly same with RI, but I don't think 
it's a big deal, I intend to delete this assert.

for - testSocket_NonBlock_BasicStatusAfterConnect, isConnected() should check 
first, following patch can fix it. And again, the test failed at same line as 
BasicStatusAfterConnect.

Following patch can fix these failures, I'd like to commit it if second 
committer agree this.

Index: 
modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
=====================================================================
--- 
modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
+++ 
modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
@@ -1008,6 +1008,10 @@ class SocketChannelImpl extends SocketChannel implements 
FileDescriptorHandler {

          @Override
          public InetAddress getInetAddress() {
+            if (!isConnected()) {
+                return null;
+            }
+
              if (channel.connectAddress == null && super.getInetAddress() != 
null) {
                  channel.connectAddress = new 
InetSocketAddress(super.getInetAddress(), super.getPort());
              }
@@ -1019,6 +1023,9 @@ class SocketChannelImpl extends SocketChannel implements 
FileDescriptorHandler {

          @Override
          public SocketAddress getRemoteSocketAddress() {
+            if (!isConnected()) {
+                return null;
+            }
              if (channel.connectAddress == null && super.getInetAddress() != 
null) {
                  channel.connectAddress = new 
InetSocketAddress(super.getInetAddress(), super.getPort());
              }
@@ -1027,6 +1034,9 @@ class SocketChannelImpl extends SocketChannel implements 
FileDescriptorHandler {

          @Override
          public int getPort() {
+            if (!isConnected()) {
+                return 0;
+            }
              if (channel.connectAddress == null && super.getInetAddress() != 
null) {
                  channel.connectAddress = new 
InetSocketAddress(super.getInetAddress(), super.getPort());
              }
Index: 
modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
=====================================================================
--- 
modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
+++ 
modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
@@ -491,8 +491,6 @@ public class SocketChannelTest extends TestCase {
          assertEquals(s.getPort(), address.getPort());
          assertNotNull(s.getLocalSocketAddress());
          assertTrue(s.getReceiveBufferSize() >= 8192);
-        // equal , not same
-        assertNotSame(s.getRemoteSocketAddress(), (SocketAddress) address);
          assertEquals(s.getRemoteSocketAddress(), (SocketAddress) address);
          // assertFalse(s.getReuseAddress());
          assertTrue(s.getSendBufferSize() >= 8192);


-- 
Best Regards,
Regis.

Mime
View raw message