Author: mturk
Date: Tue Jun 28 06:04:32 2011
New Revision: 1140446

URL: http://svn.apache.org/viewvc?rev=1140446&view=rev
Log:
Axe duplicate close() tracking. No need to complicate the things

Modified:
    
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalDescriptor.java
    
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketDescriptor.java

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalDescriptor.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalDescriptor.java?rev=1140446&r1=1140445&r2=1140446&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalDescriptor.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalDescriptor.java
 Tue Jun 28 06:04:32 2011
@@ -44,8 +44,6 @@ final class LocalDescriptor extends Desc
     private static native boolean isBlocking0(long fd)
         throws IOException;
 
-    private boolean               xclosed = false;
-
     public LocalDescriptor()
     {
     }
@@ -70,24 +68,16 @@ final class LocalDescriptor extends Desc
     public boolean isBlocking()
         throws IOException
     {
-        if (closed()) {
-            if (xclosed)
-                throw new ClosedDescriptorException();
-            else
-                throw new InvalidDescriptorException();
-        }
+        if (closed())
+            throw new ClosedDescriptorException();
         return isBlocking0(fd);
     }
 
     public LocalDescriptor configureBlocking(boolean block)
         throws IOException
     {
-        if (closed()) {
-            if (xclosed)
-                throw new ClosedDescriptorException();
-            else
-                throw new InvalidDescriptorException();
-        }
+        if (closed())
+            throw new ClosedDescriptorException();
         int rc = block0(fd, block);
         if (rc != 0)
             throw new IOException(Status.describe(rc));
@@ -98,11 +88,7 @@ final class LocalDescriptor extends Desc
     public void close()
         throws IOException
     {
-        if (xclosed)
-            throw new 
ClosedDescriptorException(Local.sm.get("socketd.CLOSED"));
-        // Guard against multiple method invocations
         // Closing an empty socket is not an error
-        xclosed = true;
         if (valid()) {
             int rc = close0(fd);
             fd     = 0L;
@@ -115,12 +101,8 @@ final class LocalDescriptor extends Desc
     public void sync()
         throws SyncFailedException, IOException
     {
-        if (closed()) {
-            if (xclosed)
-                throw new ClosedDescriptorException();
-            else
-                throw new InvalidDescriptorException();
-        }
+        if (closed())
+            throw new ClosedDescriptorException();
         int rc = sendz0(fd);
         if (rc != 0)
             throw new SocketException(Status.describe(rc));
@@ -130,12 +112,8 @@ final class LocalDescriptor extends Desc
     public void flush()
         throws SyncFailedException, IOException
     {
-        if (closed()) {
-            if (xclosed)
-                throw new ClosedDescriptorException();
-            else
-                throw new InvalidDescriptorException();
-        }
+        if (closed())
+            throw new ClosedDescriptorException();
     }
 
     /**

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketDescriptor.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketDescriptor.java?rev=1140446&r1=1140445&r2=1140446&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketDescriptor.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketDescriptor.java
 Tue Jun 28 06:04:32 2011
@@ -41,8 +41,6 @@ final class SocketDescriptor extends Des
     private static native boolean isBlocking0(long fd)
         throws IOException;
 
-    private boolean xclosed = false;
-
     public SocketDescriptor()
     {
     }
@@ -61,24 +59,16 @@ final class SocketDescriptor extends Des
     public boolean isBlocking()
         throws IOException
     {
-        if (closed()) {
-            if (xclosed)
-                throw new ClosedDescriptorException();
-            else
-                throw new InvalidDescriptorException();
-        }
+        if (closed())
+            throw new ClosedDescriptorException();
         return isBlocking0(fd);
     }
 
     public SocketDescriptor configureBlocking(boolean block)
         throws IOException
     {
-        if (closed()) {
-            if (xclosed)
-                throw new ClosedDescriptorException();
-            else
-                throw new InvalidDescriptorException();
-        }
+        if (closed())
+            throw new ClosedDescriptorException();
         int rc = block0(fd, block);
         if (rc != 0)
             throw new IOException(Status.describe(rc));
@@ -89,11 +79,7 @@ final class SocketDescriptor extends Des
     public void close()
         throws IOException
     {
-        if (xclosed)
-            throw new 
ClosedDescriptorException(Local.sm.get("socketd.CLOSED"));
-        // Guard against multiple method invocations
         // Closing an empty socket is not an error
-        xclosed = true;
         if (valid()) {
             int rc = close0(fd);
             fd     = 0L;
@@ -106,12 +92,8 @@ final class SocketDescriptor extends Des
     public void sync()
         throws SyncFailedException, IOException
     {
-        if (closed()) {
-            if (xclosed)
-                throw new ClosedDescriptorException();
-            else
-                throw new InvalidDescriptorException();
-        }
+        if (closed())
+            throw new ClosedDescriptorException();
         int rc = sendz0(fd);
         if (rc != 0)
             throw new SocketException(Status.describe(rc));
@@ -121,12 +103,8 @@ final class SocketDescriptor extends Des
     public void flush()
         throws SyncFailedException, IOException
     {
-        if (closed()) {
-            if (xclosed)
-                throw new ClosedDescriptorException();
-            else
-                throw new InvalidDescriptorException();
-        }
+        if (closed())
+            throw new ClosedDescriptorException();
     }
 
     /**


Reply via email to