[jira] [Comment Edited] (SLING-11458) Regress - "Writer has already been closed" exception in GraphQLServlet

2022-11-21 Thread Radu Cotescu (Jira)


[ 
https://issues.apache.org/jira/browse/SLING-11458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17636659#comment-17636659
 ] 

Radu Cotescu edited comment on SLING-11458 at 11/21/22 12:16 PM:
-

[~andysch], no, I didn't have the time to start a PR for the issue mentioned in 
https://lists.apache.org/thread/lytsl0b23d56xkmvsvnoxm4d7skxcq5h (comment to 
your original PR).

But like [~kwin] already suggested, we should not skip calling the original 
{{close}} method, since it might do more than just closing the writer. Again, 
we should fix the chain of calls we see in the stack trace you posted.


was (Author: radu.cotescu):
[~andysch], no, I didn't have the time to start a PR for the issue mentioned in 
https://lists.apache.org/thread/lytsl0b23d56xkmvsvnoxm4d7skxcq5h (comment to 
your original PR).

> Regress - "Writer has already been closed" exception in GraphQLServlet
> --
>
> Key: SLING-11458
> URL: https://issues.apache.org/jira/browse/SLING-11458
> Project: Sling
>  Issue Type: Bug
>  Components: GraphQL
>Affects Versions: GraphQL Core 0.0.4
>Reporter: Evgeny Tugarev
>Assignee: Andreas Schaefer
>Priority: Major
>
> The GraphQLServlet shouldn't call {{response.getWriter().flush()}} as the 
> {{JsonWriter}} used by the {{JsonSerializer}} implements {{Closeable}} and as 
> such [closes the 
> Writer|https://github.com/jdereg/json-io/blob/cf849f15460decf10a8a320390de11965bb5996b/src/main/java/com/cedarsoftware/util/io/JsonWriter.java#L2413].
> This causes a "Writer has already been closed" Exception when {{flush()}} is 
> called.
> This was fixed in commit d27f4bb7 but then this commit: 11c7e389 did undo the 
> fix as now the JsonWriter is closed when existing the try-catch block.
> I will undo it and prevent the premature closure as this is causing issues 
> like when the call to this servlet is made through a dispatcher.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (SLING-11458) Regress - "Writer has already been closed" exception in GraphQLServlet

2022-11-16 Thread Andreas Schaefer (Jira)


[ 
https://issues.apache.org/jira/browse/SLING-11458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17634573#comment-17634573
 ] 

Andreas Schaefer edited comment on SLING-11458 at 11/16/22 10:02 PM:
-

The problem here is that the Johnzon's JsonWriter is closing the enclosed 
Servlet Print Writer which then will cause the WriterAlreadyClosedException 
when the Rewriter Response wants to flush the Print Writer.
If we would not use the JsonWriter we would not have this issue because the 
PrintWriter is not bound to the try-block. 


was (Author: schaefa):
The problem here is that the Johnson's JsonWriter is closing the enclosed 
Servlet Print Writer which then will cause the WriterAlreadyClosedException 
when the Rewriter Response wants to flush the Print Writer.
If we would not use the JsonWriter we would not have this issue because the 
PrintWriter is not bound to the try-block. 

> Regress - "Writer has already been closed" exception in GraphQLServlet
> --
>
> Key: SLING-11458
> URL: https://issues.apache.org/jira/browse/SLING-11458
> Project: Sling
>  Issue Type: Bug
>  Components: GraphQL
>Affects Versions: GraphQL Core 0.0.4
>Reporter: Evgeny Tugarev
>Assignee: Andreas Schaefer
>Priority: Major
>
> The GraphQLServlet shouldn't call {{response.getWriter().flush()}} as the 
> {{JsonWriter}} used by the {{JsonSerializer}} implements {{Closeable}} and as 
> such [closes the 
> Writer|https://github.com/jdereg/json-io/blob/cf849f15460decf10a8a320390de11965bb5996b/src/main/java/com/cedarsoftware/util/io/JsonWriter.java#L2413].
> This causes a "Writer has already been closed" Exception when {{flush()}} is 
> called.
> This was fixed in commit d27f4bb7 but then this commit: 11c7e389 did undo the 
> fix as now the JsonWriter is closed when existing the try-catch block.
> I will undo it and prevent the premature closure as this is causing issues 
> like when the call to this servlet is made through a dispatcher.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)