You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Sergey Kuksenko (JIRA)" <ji...@apache.org> on 2007/05/31 18:28:16 UTC

[jira] Created: (HARMONY-4017) [classlib] incorrect error processing in file reading (Windows) caused failure on org.apache.harmony.nio.tests.java.nio.channels.FileLockInterruptionExceptionTest

[classlib] incorrect error processing in file reading (Windows) caused failure on org.apache.harmony.nio.tests.java.nio.channels.FileLockInterruptionExceptionTest
------------------------------------------------------------------------------------------------------------------------------------------------------------------

                 Key: HARMONY-4017
                 URL: https://issues.apache.org/jira/browse/HARMONY-4017
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
         Environment: Windows.
            Reporter: Sergey Kuksenko


"hyfile_read" function incorrectly process errors.

See part of code:
  if (!ReadFile ((HANDLE) fd, buf, nbytes, &bytesRead, NULL))
    {
      I_32 error = GetLastError ();
      portLibrary->error_set_last_error (portLibrary, error, findError (error));
      return -1;
    }
  if (bytesRead == 0)
    {
      return -1;
    }
---------------
Here if "ReadFile"  returns a failure then "hyfile_read" set the last error and return -1.
In case of correct operation with reading zero bytes (we are at the End Of File)  "hyfile_read" returns also -1.
This both situations can't be distingueshed from "hyfile_read" caller.
"OSFileSystem.readImpl" do the following
------------------
  result =
    (jlong) hyfile_read ((IDATA) fd, (void *) (bytes + offset),
                         (IDATA) nbytes);
  if(result == -1 && hyerror_last_error_number() == HYPORT_ERROR_FILE_LOCKED){
    throwNewExceptionByName(env, "java/io/IOException", netLookupErrorString(env, HYPORT_ERROR_FILE_LOCKED));
--------------
So URLClassLoader tries to load "FileLockInterruptionExceptionTest.class", read 942 bytes, try to read next bytes (when reading from InputStream we need to get "-1" as mark of EOF).  And here is all ok. 
But in the test suit before this test another test was executed.
The previous test was really tested File Lock Error. And port library last error contains prev error number.
And exception was thrown. Otherwords we've got the follwoing sequence of IO operations:
1. FileLockedError.
2. Correct reading from file.
3. Read from file, got "-1" as EOF, look into last error state, found obsolete FileLockedError, throws exception.
thus in case of success IO operation hyfile needs to clean last error state.

Attached file fix the situation with "FileLockInterruptionExceptionTest"
But probably error results from hyfile_read should be refactored or etc. and needs more evaluation.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (HARMONY-4017) [classlib] incorrect error processing in file reading (Windows) caused failure on org.apache.harmony.nio.tests.java.nio.channels.FileLockInterruptionExceptionTest

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4017?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov resolved HARMONY-4017.
--------------------------------------

    Resolution: Fixed

Thanks Sergey. I've applied the patch at r543217. Please verify it is ok.

> [classlib] incorrect error processing in file reading (Windows) caused failure on org.apache.harmony.nio.tests.java.nio.channels.FileLockInterruptionExceptionTest
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4017
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4017
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: Windows.
>            Reporter: Sergey Kuksenko
>            Assignee: Alexei Zakharov
>         Attachments: file.patch
>
>
> "hyfile_read" function incorrectly process errors.
> See part of code:
>   if (!ReadFile ((HANDLE) fd, buf, nbytes, &bytesRead, NULL))
>     {
>       I_32 error = GetLastError ();
>       portLibrary->error_set_last_error (portLibrary, error, findError (error));
>       return -1;
>     }
>   if (bytesRead == 0)
>     {
>       return -1;
>     }
> ---------------
> Here if "ReadFile"  returns a failure then "hyfile_read" set the last error and return -1.
> In case of correct operation with reading zero bytes (we are at the End Of File)  "hyfile_read" returns also -1.
> This both situations can't be distingueshed from "hyfile_read" caller.
> "OSFileSystem.readImpl" do the following
> ------------------
>   result =
>     (jlong) hyfile_read ((IDATA) fd, (void *) (bytes + offset),
>                          (IDATA) nbytes);
>   if(result == -1 && hyerror_last_error_number() == HYPORT_ERROR_FILE_LOCKED){
>     throwNewExceptionByName(env, "java/io/IOException", netLookupErrorString(env, HYPORT_ERROR_FILE_LOCKED));
> --------------
> So URLClassLoader tries to load "FileLockInterruptionExceptionTest.class", read 942 bytes, try to read next bytes (when reading from InputStream we need to get "-1" as mark of EOF).  And here is all ok. 
> But in the test suit before this test another test was executed.
> The previous test was really tested File Lock Error. And port library last error contains prev error number.
> And exception was thrown. Otherwords we've got the follwoing sequence of IO operations:
> 1. FileLockedError.
> 2. Correct reading from file.
> 3. Read from file, got "-1" as EOF, look into last error state, found obsolete FileLockedError, throws exception.
> thus in case of success IO operation hyfile needs to clean last error state.
> Attached file fix the situation with "FileLockInterruptionExceptionTest"
> But probably error results from hyfile_read should be refactored or etc. and needs more evaluation.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-4017) [classlib] incorrect error processing in file reading (Windows) caused failure on org.apache.harmony.nio.tests.java.nio.channels.FileLockInterruptionExceptionTest

Posted by "Sergey Kuksenko (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4017?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sergey Kuksenko updated HARMONY-4017:
-------------------------------------

    Attachment: file.patch

I've checked this patch on all tests, but hope it will be double checked.

> [classlib] incorrect error processing in file reading (Windows) caused failure on org.apache.harmony.nio.tests.java.nio.channels.FileLockInterruptionExceptionTest
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4017
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4017
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: Windows.
>            Reporter: Sergey Kuksenko
>         Attachments: file.patch
>
>
> "hyfile_read" function incorrectly process errors.
> See part of code:
>   if (!ReadFile ((HANDLE) fd, buf, nbytes, &bytesRead, NULL))
>     {
>       I_32 error = GetLastError ();
>       portLibrary->error_set_last_error (portLibrary, error, findError (error));
>       return -1;
>     }
>   if (bytesRead == 0)
>     {
>       return -1;
>     }
> ---------------
> Here if "ReadFile"  returns a failure then "hyfile_read" set the last error and return -1.
> In case of correct operation with reading zero bytes (we are at the End Of File)  "hyfile_read" returns also -1.
> This both situations can't be distingueshed from "hyfile_read" caller.
> "OSFileSystem.readImpl" do the following
> ------------------
>   result =
>     (jlong) hyfile_read ((IDATA) fd, (void *) (bytes + offset),
>                          (IDATA) nbytes);
>   if(result == -1 && hyerror_last_error_number() == HYPORT_ERROR_FILE_LOCKED){
>     throwNewExceptionByName(env, "java/io/IOException", netLookupErrorString(env, HYPORT_ERROR_FILE_LOCKED));
> --------------
> So URLClassLoader tries to load "FileLockInterruptionExceptionTest.class", read 942 bytes, try to read next bytes (when reading from InputStream we need to get "-1" as mark of EOF).  And here is all ok. 
> But in the test suit before this test another test was executed.
> The previous test was really tested File Lock Error. And port library last error contains prev error number.
> And exception was thrown. Otherwords we've got the follwoing sequence of IO operations:
> 1. FileLockedError.
> 2. Correct reading from file.
> 3. Read from file, got "-1" as EOF, look into last error state, found obsolete FileLockedError, throws exception.
> thus in case of success IO operation hyfile needs to clean last error state.
> Attached file fix the situation with "FileLockInterruptionExceptionTest"
> But probably error results from hyfile_read should be refactored or etc. and needs more evaluation.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (HARMONY-4017) [classlib] incorrect error processing in file reading (Windows) caused failure on org.apache.harmony.nio.tests.java.nio.channels.FileLockInterruptionExceptionTest

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4017?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov reassigned HARMONY-4017:
----------------------------------------

    Assignee: Alexei Zakharov

> [classlib] incorrect error processing in file reading (Windows) caused failure on org.apache.harmony.nio.tests.java.nio.channels.FileLockInterruptionExceptionTest
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4017
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4017
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: Windows.
>            Reporter: Sergey Kuksenko
>            Assignee: Alexei Zakharov
>         Attachments: file.patch
>
>
> "hyfile_read" function incorrectly process errors.
> See part of code:
>   if (!ReadFile ((HANDLE) fd, buf, nbytes, &bytesRead, NULL))
>     {
>       I_32 error = GetLastError ();
>       portLibrary->error_set_last_error (portLibrary, error, findError (error));
>       return -1;
>     }
>   if (bytesRead == 0)
>     {
>       return -1;
>     }
> ---------------
> Here if "ReadFile"  returns a failure then "hyfile_read" set the last error and return -1.
> In case of correct operation with reading zero bytes (we are at the End Of File)  "hyfile_read" returns also -1.
> This both situations can't be distingueshed from "hyfile_read" caller.
> "OSFileSystem.readImpl" do the following
> ------------------
>   result =
>     (jlong) hyfile_read ((IDATA) fd, (void *) (bytes + offset),
>                          (IDATA) nbytes);
>   if(result == -1 && hyerror_last_error_number() == HYPORT_ERROR_FILE_LOCKED){
>     throwNewExceptionByName(env, "java/io/IOException", netLookupErrorString(env, HYPORT_ERROR_FILE_LOCKED));
> --------------
> So URLClassLoader tries to load "FileLockInterruptionExceptionTest.class", read 942 bytes, try to read next bytes (when reading from InputStream we need to get "-1" as mark of EOF).  And here is all ok. 
> But in the test suit before this test another test was executed.
> The previous test was really tested File Lock Error. And port library last error contains prev error number.
> And exception was thrown. Otherwords we've got the follwoing sequence of IO operations:
> 1. FileLockedError.
> 2. Correct reading from file.
> 3. Read from file, got "-1" as EOF, look into last error state, found obsolete FileLockedError, throws exception.
> thus in case of success IO operation hyfile needs to clean last error state.
> Attached file fix the situation with "FileLockInterruptionExceptionTest"
> But probably error results from hyfile_read should be refactored or etc. and needs more evaluation.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.