Hi Martin,

I changed the wording of the method readPartially to readBuffered. (default true) it is much better for understanding this way.

The change you mentioned (WICKET-5819 - Do not close stream if read partially) is important, because in case of ByteArrayInputStream (readBuffered = true) the stream can be closed because it is wrapped into a new ByteArrayInputStream. If the original InputStream is used the resource is going to be read from disk directly to response. So it must not closed, because the PartWriterCallback is writing the stuff based on that stream. (otherwise there would be a stream closed exception while writing the content to response)

See:
 
https://github.com/apache/wicket/blob/7e3fed6dce27d1cc5c68c7901eecec08091d59c4/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResource.java#L342

kind regards

Tobias

P.S.: Changes that targets your suggestions (sorry that they are split into three commits - but they are rather easy to review):

https://github.com/apache/wicket/commit/7a837f605f0df3777f5a3a2b70d3f1142f32a1f4
https://github.com/apache/wicket/commit/3d935e5d483b4f9cb8415d16fc4e94c94e843abd
https://github.com/apache/wicket/commit/86bedde28dbdc32e1a9dfbc92a903b8733e96549


Am 25.05.15 um 22:05 schrieb Martin Grigorov:
Hi Tobias,

"readPartially" sounds to me like related to "Partial content, code 206",
i.e. related to the functionality about ranges.
Maybe "readBuffered"?

The change at
https://git1-us-west.apache.org/repos/asf/wicket/repo?p=wicket.git;a=commitdiff;h=7e3fed6dce27d1cc5c68c7901eecec08091d59c4;hp=b3c9843f805560f6685106b97cd2f9ddab8c28a9
is not very clear to me. Why it is needed exactly?
How the buffering leads to the need to not closing the resource stream?

I've made some comments in GitHub about small things in the javadoc
improvements. Did you receive notifications?




Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Sun, May 24, 2015 at 2:48 PM, Tobias Soloschenko <
[email protected]> wrote:

Hello everyone,

I just want to introduce a new fluent method to PackageResource /
PackageResourceReference which is called readPartially(boolean). It
adresses a memory consumption issue while reading media files (audio,
video) or other large resource files.

Before this implementation the content of each file shipped with a
PackageResourceReference were copied into memory and then the part the
client requested (Content-Range, Range, Accept-Range) was transfered to the
client.

Now only the part the client requested is read and transfered directly to
the response, without storing it into memory (ByteArrayInputStream, byte[])
- For normal the PackageResourceReference is reading it from disk.

If the method isn't invoked or invoked with false the old behavior is used.

The only limitation is that no
org.apache.wicket.resource.ITextResourceCompressor will be used if the flag
is set to true, because the content will not be analyzed.

I decided to first put it into a branch and discuss it here:

Branch: https://github.com/apache/wicket/compare/WICKET-5819_Improvements
Ticket: https://issues.apache.org/jira/browse/WICKET-5819

What do you think?

kind regards

Tobias


Reply via email to