6988037: fileClose prints debug message if close fails

Alan Bateman Alan.Bateman at oracle.com
Wed Sep 29 12:25:35 UTC 2010


I need a reviewer for a small change to remove a debug message that 
someone left when fixing a bug in the java.io implementation early in 
jdk7. The debug message is printed if closing a file fails (for example 
EIO because of a NFS stale handle).  That change also added code to 
restore the file descriptor field but this isn't needed because the 
stream classes have a closed flag to ensure that they only attempt to 
close the underlying file descriptor once. Furthermore, if close fails 
then the state of the file descriptor is unspecified and so cannot be 
used again. The proposed patch is attached.

Thanks,
Alan.

diff --git a/src/solaris/native/java/io/io_util_md.c 
b/src/solaris/native/java/io/io_util_md.c
--- a/src/solaris/native/java/io/io_util_md.c
+++ b/src/solaris/native/java/io/io_util_md.c
@@ -83,8 +83,6 @@ fileClose(JNIEnv *env, jobject this, jfi
             close(devnull);
         }
     } else if (JVM_Close(fd) == -1) {
-            SET_FD(this, fd, fid); // restore fd
-            printf("JVM_Close returned -1\n");
-            JNU_ThrowIOExceptionWithLastError(env, "close failed");
+        JNU_ThrowIOExceptionWithLastError(env, "close failed");
     }
 }
diff --git a/src/windows/native/java/io/io_util_md.c 
b/src/windows/native/java/io/io_util_md.c
--- a/src/windows/native/java/io/io_util_md.c
+++ b/src/windows/native/java/io/io_util_md.c
@@ -531,7 +531,6 @@ handleClose(JNIEnv *env, jobject this, j
     SET_FD(this, -1, fid);
 
     if (CloseHandle(h) == 0) { /* Returns zero on failure */
-        SET_FD(this, fd, fid); // restore fd
         JNU_ThrowIOExceptionWithLastError(env, "close failed");
     }
     return 0;




More information about the core-libs-dev mailing list