SLING-11458 - fixed a regresssion for the original Ticket SLING-9626#29
SLING-11458 - fixed a regresssion for the original Ticket SLING-9626#29schaefa wants to merge 4 commits into
Conversation
The Json Writer that wraps the response writer must not be flushed or closed as this can lead to issues down the chain
|
I would suggest using https://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/output/CloseShieldWriter.html#wrap-java.io.Writer- instead. Then you can continue using try with resources because not calling close on JSONWriter is dangerous as it might perform other operations than just closing the underlying writer. |
|
@kwin First this does not work as it replaces the writer when closed is called but I also think that we should make it explicit there as this is important. Also SonarCloud is wrong here - I think. |
I am not following here. You can just use
I think using
In this particular case maybe yes, but as stated above, it may be possible that in the future another implementation of JSONWriter may do necessary cleanup in its |
|
@kwin The Close Shield Writer is not just preventing the close but it is replacing the writer: This will lead to failures in the IT tests of this module but I am pretty sure this will lead to issues when using it. |
|
|
|
@kwin You give it a try (on both execute() methods): This will yield 4 IT test failure: [ERROR] Errors: No failure with my solution |
|
Updated the code to use a Wrapper to prevent the closure to satisfy the SonarCloud code check |
|
Kudos, SonarCloud Quality Gate passed! |
|
This issue should be fixed in Sling in a more generic way and not only in this module - see https://lists.apache.org/thread/lytsl0b23d56xkmvsvnoxm4d7skxcq5h for more details. |
|
Kudos, SonarCloud Quality Gate passed! |
2 similar comments
|
Kudos, SonarCloud Quality Gate passed! |
|
Kudos, SonarCloud Quality Gate passed! |
|
|
|
|
3 similar comments
|
|
|











The Json Writer that wraps the response writer must not be flushed or closed as this can lead to issues down the chain