changeset 9688:2ef6a91ab99f

7043788: (fs) PosixFileAttributes.owner() or group() throws NPE if owner/group not in passwd/group database Reviewed-by: chegar
author alanb
date Wed, 11 May 2011 15:00:16 +0100
parents e41f9c6d9c0d
children 53a4e9b16900
files jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
diffstat 1 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c	Wed May 11 14:57:17 2011 +0100
+++ b/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c	Wed May 11 15:00:16 2011 +0100
@@ -892,8 +892,9 @@
 
         if (res != 0 || p == NULL || p->pw_name == NULL || *(p->pw_name) == '\0') {
             /* not found or error */
-            if (errno != 0 && errno != ENOENT)
-                throwUnixException(env, errno);
+            if (errno == 0)
+                errno = ENOENT;
+            throwUnixException(env, errno);
         } else {
             jsize len = strlen(p->pw_name);
             result = (*env)->NewByteArray(env, len);
@@ -941,14 +942,14 @@
         retry = 0;
         if (res != 0 || g == NULL || g->gr_name == NULL || *(g->gr_name) == '\0') {
             /* not found or error */
-            if (errno != 0 && errno != ENOENT) {
-                if (errno == ERANGE) {
-                    /* insufficient buffer size so need larger buffer */
-                    buflen += ENT_BUF_SIZE;
-                    retry = 1;
-                } else {
-                    throwUnixException(env, errno);
-                }
+            if (errno == ERANGE) {
+                /* insufficient buffer size so need larger buffer */
+                buflen += ENT_BUF_SIZE;
+                retry = 1;
+            } else {
+                if (errno == 0)
+                    errno = ENOENT;
+                throwUnixException(env, errno);
             }
         } else {
             jsize len = strlen(g->gr_name);