You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@shindig.apache.org by "Radu Dumitriu (JIRA)" <ji...@apache.org> on 2011/01/04 18:34:46 UTC
[jira] Updated: (SHINDIG-1483) Wrong memory alloc in
org.apache.shindig.gadgets.rewrite.lexer.DefaultContentRewriter
[ https://issues.apache.org/jira/browse/SHINDIG-1483?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Radu Dumitriu updated SHINDIG-1483:
-----------------------------------
Affects Version/s: 1.0.1
> Wrong memory alloc in org.apache.shindig.gadgets.rewrite.lexer.DefaultContentRewriter
> -------------------------------------------------------------------------------------
>
> Key: SHINDIG-1483
> URL: https://issues.apache.org/jira/browse/SHINDIG-1483
> Project: Shindig
> Issue Type: Bug
> Components: Java
> Affects Versions: 1.0.1
> Reporter: Radu Dumitriu
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> Where: org.apache.shindig.gadgets.rewrite.lexer.DefaultContentRewriter, lines: 100, 101
> What:
> ByteArrayOutputStream baos = new ByteArrayOutputStream((content.getContent().length() * 110) / 100);
> should be:
> ByteArrayOutputStream baos = new ByteArrayOutputStream((int)(content.getContent().length() * 1.10) );
> Reason:
> For very large content (20Mb), the content gets multiplied first by 110, overflows, then remains negative. Any allocation will fail, as expected.
> Also: rewriting in memory the entire content pops up the memory usage; a different strategy should be in place if content is very large (let's say, greater than 4Mb).
> SVN Diff:
> $ svn diff DefaultContentRewriter.java
> Index: DefaultContentRewriter.java
> ===================================================================
> --- DefaultContentRewriter.java (revision 1049525)
> +++ DefaultContentRewriter.java (working copy)
> @@ -98,7 +98,7 @@
> MutableContent content) {
> try {
> ByteArrayOutputStream baos = new ByteArrayOutputStream(
> - (content.getContent().length() * 110) / 100);
> + (int)(content.getContent().length() * 1.10) );
> OutputStreamWriter output = new OutputStreamWriter(baos, original.getEncoding());
> String mimeType = original.getHeader("Content-Type");
> if (request.getRewriteMimeType() != null) {
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.