FilePart.sendData does not complain about missing file
------------------------------------------------------

                 Key: HTTPCLIENT-878
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-878
             Project: HttpComponents HttpClient
          Issue Type: Improvement
          Components: HttpClient
    Affects Versions: Snapshot
            Reporter: Benjamin Riefenstahl
            Priority: Minor


The situation in my code was this:

* Create a FilePartSource from an existing file.
* Do some housekeeping.
* Call HttpClient.executeMethod.

My bug was that HttpClient.executeMethod just sent an empty file.

My own problem was that the "housekeeping" mentioned above had moved
the file.

The intermediate culprit turned out to be FilePart.sendData.  It calls
FilePart.lengthOfData before opening the file stream.  lengthOfData
boils down to File.length which returns 0 if the file does not exist
and in that case FilePart avoids opening the file.

While this is a bug in my code, I wish that FilePart.sendData would
throw an exception in this situation, so that this error is more
easily seen and is more likely to come up during unit testing.  The
check could also go into FilePartSource.getLength.

It should be noted that the constructor of FilePartSource does check
that the file exists, but FilePartSource.getLength and
FilePart.sendData do not repeat that check.

I can create a patch, if that is necessary.


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to