Hello Tim,

thanks a lot for having entered an issue. This has been fixed (I've checked
with your code) a few minutes earlier, see
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2682395
.
The remaining size of a target buffer was not taken into account when
filling it.

Best regards,
Thierry Boileau


I just filed issue 1198 which has one file Java program that demonstrates
> the problem.
>
> http://restlet.tigris.org/issues/show_bug.cgi?id=1198
>
> <http://restlet.tigris.org/issues/show_bug.cgi?id=1198>--tim
>
>
> On Mon, Nov 8, 2010 at 9:03 PM, Tim Peierls <t...@peierls.net> wrote:
>
>> On Wed, Jul 28, 2010 at 6:27 PM, Tim Peierls <t...@peierls.net> wrote:
>>
>>> I wrote a Restlet Filter to minify application/x-javascript resources in
>>> afterHandle (using JSMin now, but I'll probably switch to YUI Compressor).
>>>
>>
>> As of 2.1-M1 (JSE edition), and using the internal connector only, I'm
>> getting a BufferOverflowException when I use this code in afterHandle:
>>
>> Representation result =
>>     new WriterRepresentation(mediaType, out.size()) {
>>         public void write(Writer writer) throws IOException {
>>             out.writeTo(writer);
>>         }
>>     };
>> response.setEntity(result);
>>
>>
>> where "out" is a CharArrayWriter that has been written to by a
>> YUICompressor instance and then flushed. It seems to only happen on fairly
>> large files, so it might be another manifestation of the
>> BufferOverflowException bug that was fixed back in January or so. I was
>> getting a different kind of exception in 2.0.x, something about writing to
>> closed socket, but it wasn't preventing things from working, whereas this
>> is.
>>
>> As a workaround, I'm using this code:
>>
>> Representation result =
>>     new StringRepresentation(out.toString());
>> response.setEntity(result);
>>
>>
>> which means creating a copy of the entire minified file in memory, but
>> works with no warnings.
>>
>> Another thing that might be worth mentioning is that the Filter this code
>> is part of is wrapped around a Directory with this code:
>>
>>     private Restlet getDirectoryOptionallyMinified(String path, boolean
>> minify) {
>>         // XXX Can't figure out how to do this with Reference
>> construction,
>>         //     but it doesn't matter.
>>         String ref = createClapReference(getClass().getPackage()) + "/" +
>> path;
>>         Restlet directory = new Directory(getContext(), ref);
>>         if (minify) {
>>             Filter minified = new MinificationFilter();
>>             minified.setNext(directory);
>>             directory = minified;
>>         }
>>         return directory;
>>     }
>>
>> If no one sees any obvious gaffes in this code, I'll try to turn it into a
>> simple test program that illustrates the problem.
>>
>> --tim
>>
>
>

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2682449

Reply via email to