Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excessive memory use & GC caused by use of exception for control flow #5

Open
glassfishrobot opened this issue Mar 22, 2016 · 5 comments

Comments

@glassfishrobot
Copy link

Construction or initialization of a JspWriterImpl results in an attempt to set the buffer size the result of which may be an IllegalStateException.

This can be reduced by simply checking to see if the response is committed instead, and avoid the exception as control flow.

Environment

any

Affected Versions

[current]

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
Reported by rotty

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
Was assigned to super_glassfish

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
rotty said:
patch

======================================
diff --git a/org/apache/jasper/runtime/JspWriterImpl.java b/org/apache/jasper/runtime/JspWriterImpl.java
index ead4f5e..9d09f67 100644
— a/org/apache/jasper/runtime/JspWriterImpl.java
+++ b/org/apache/jasper/runtime/JspWriterImpl.java
@@ -139,13 +139,16 @@ public class JspWriterImpl extends JspWriter {
throw new IllegalArgumentException("Buffer size <= 0");
this.response = response;
allocateCharBuffer();

  • // START OF IASRI 4641975/6172992

  • try { - response.setBufferSize(sz); - } catch (IllegalStateException ise) { - // ignore - }

    • // END OF IASRI 4641975/6172992
    • if (!response.isCommitted()) {
    • // START OF IASRI 4641975/6172992
    • try { + response.setBufferSize(sz); + } catch (IllegalStateException ise) { + // ignore + }
    • // END OF IASRI 4641975/6172992
    • }
      }

    void init( ServletResponse response, int sz, boolean autoFlush ) {
    @@ -153,13 +156,16 @@ public class JspWriterImpl extends JspWriter {
    this.autoFlush=autoFlush;
    this.bufferSize=sz;
    allocateCharBuffer();

    • // START OF IASRI 4641975/6172992
    • try { - response.setBufferSize(sz); - }

    catch (IllegalStateException ise)

    { - // ignore - }

  • // END OF IASRI 4641975/6172992
    +

    • if (!response.isCommitted())Unknown macro: {+ // START OF IASRI 4641975/6172992+ try { + response.setBufferSize(sz); + } catch (IllegalStateException ise) { + // ignore + }+ // END OF IASRI 4641975/6172992+ }

    }

/** Package-level access

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
This issue was imported from java.net JIRA JSP-51

@glassfishrobot
Copy link
Author

@glassfishrobot glassfishrobot self-assigned this Aug 17, 2018
@markt-asf markt-asf transferred this issue from jakartaee/pages Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant