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 2010/12/15 14:51:02 UTC
[jira] Created: (SHINDIG-1483) Wrong memory alloc in
org.apache.shindig.gadgets.rewrite.lexer.DefaultContentRewriter
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
Reporter: Radu Dumitriu
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.
[jira] Commented: (SHINDIG-1483) Wrong memory alloc in
org.apache.shindig.gadgets.rewrite.lexer.DefaultContentRewriter
Posted by "Radu Dumitriu (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SHINDIG-1483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12977367#action_12977367 ]
Radu Dumitriu commented on SHINDIG-1483:
----------------------------------------
Yes, you're right, the version is 1.0.1, bundled with Atlassian JIRA, version 4.x. Some plugin loads a huge amount of data and dies.
$ svn info
Path: .
URL: http://svn.apache.org/repos/asf/shindig/tags/shindig-project-1.0.1
Repository Root: http://svn.apache.org/repos/asf
[....]
> 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.
[jira] Commented: (SHINDIG-1483) Wrong memory alloc in
org.apache.shindig.gadgets.rewrite.lexer.DefaultContentRewriter
Posted by "Paul Lindner (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SHINDIG-1483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12973153#action_12973153 ]
Paul Lindner commented on SHINDIG-1483:
---------------------------------------
This is from some older pre-2.0.x code, yes?
I think this has been resolved in trunk.
> 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
> 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.
[jira] Updated: (SHINDIG-1483) Wrong memory alloc in
org.apache.shindig.gadgets.rewrite.lexer.DefaultContentRewriter
Posted by "Radu Dumitriu (JIRA)" <ji...@apache.org>.
[ 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.
[jira] Closed: (SHINDIG-1483) Wrong memory alloc in
org.apache.shindig.gadgets.rewrite.lexer.DefaultContentRewriter
Posted by "Paul Lindner (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/SHINDIG-1483?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul Lindner closed SHINDIG-1483.
---------------------------------
Resolution: Won't Fix
no plans for any 1.0x releases.
> 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.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira