You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Bertrand Guay-Paquet (JIRA)" <ji...@apache.org> on 2012/07/03 15:43:19 UTC
[jira] [Created] (WICKET-4637)
HeaderBufferingWebResponse#writeMetaData(WebResponse) throws
ConcurrentModificationException when invoked in a link handler
Bertrand Guay-Paquet created WICKET-4637:
--------------------------------------------
Summary: HeaderBufferingWebResponse#writeMetaData(WebResponse) throws ConcurrentModificationException when invoked in a link handler
Key: WICKET-4637
URL: https://issues.apache.org/jira/browse/WICKET-4637
Project: Wicket
Issue Type: Bug
Components: wicket
Affects Versions: 1.5.7
Reporter: Bertrand Guay-Paquet
This ticket follows from the email thread http://markmail.org/thread/uk5y4ddoopntmkgd
I use the following ReplaceHandlerException to trigger a redirect which restarts the response but does not discard the response's meta data (e.g. cookies).
/**
* Response restarting exception which does not reset the header meta data.
*/
public class NonResettingRestartException extends ReplaceHandlerException {
public NonResettingRestartException(final Class<? extends Page> pageClass,
final PageParameters params, final RequestCycle cycle) {
super(createRequestHandler(pageClass, params), true);
Response response = cycle.getResponse();
if (response instanceof IMetaDataBufferingWebResponse) {
IMetaDataBufferingWebResponse bufferingWebResponse = (IMetaDataBufferingWebResponse) response;
WebResponse originalResponse = (WebResponse) cycle
.getOriginalResponse();
bufferingWebResponse.writeMetaData(originalResponse);
}
}
private static IRequestHandler createRequestHandler(
Class<? extends Page> pageClass, PageParameters params) {
return new RenderPageRequestHandler(new PageProvider(pageClass, params));
}
}
When this exception is thrown from a link handler, a ConcurrentModificationException occurs with the following stack trace:
HeaderBufferingWebResponse.addCookie(Cookie) line: 72
BufferedWebResponse$AddCookieAction.invoke(WebResponse) line: 240
BufferedWebResponse.writeMetaData(WebResponse) line: 75
HeaderBufferingWebResponse.writeMetaData(WebResponse) line: 205
NonResettingRestartException.<init>(Class<Page>, PageParameters, RequestCycle) line: 28
LinkPage$4.onClick() line: 38
Analysis:
1) HeaderBufferingWebResponse delegates #writeMetaData() to its bufferedResponse (a BufferedWebResponse instance).
2) BufferedWebResponse iterates its action list with the single "AddCookieAction" and invoke()s it
3) BufferedWebResponse$AddCookieAction.invoke does "response.addCookie(cookie)"
4) The addCookie is executed with this==BufferedWebResponse from 2) which modifies the action list illegally
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (WICKET-4637)
HeaderBufferingWebResponse#writeMetaData(WebResponse) throws
ConcurrentModificationException when invoked in a link handler
Posted by "Bertrand Guay-Paquet (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-4637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13405932#comment-13405932 ]
Bertrand Guay-Paquet commented on WICKET-4637:
----------------------------------------------
Steps to reproduce:
1-http://localhost:8080/
2-click on "Page with links to redirect"
3-click on "throw new NonResettingRestartException()"
> HeaderBufferingWebResponse#writeMetaData(WebResponse) throws ConcurrentModificationException when invoked in a link handler
> ---------------------------------------------------------------------------------------------------------------------------
>
> Key: WICKET-4637
> URL: https://issues.apache.org/jira/browse/WICKET-4637
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.5.7
> Reporter: Bertrand Guay-Paquet
> Labels: response
> Attachments: wicket-4637.zip
>
>
> This ticket follows from the email thread http://markmail.org/thread/uk5y4ddoopntmkgd
> I use the following ReplaceHandlerException to trigger a redirect which restarts the response but does not discard the response's meta data (e.g. cookies).
> /**
> * Response restarting exception which does not reset the header meta data.
> */
> public class NonResettingRestartException extends ReplaceHandlerException {
> public NonResettingRestartException(final Class<? extends Page> pageClass,
> final PageParameters params, final RequestCycle cycle) {
> super(createRequestHandler(pageClass, params), true);
> Response response = cycle.getResponse();
> if (response instanceof IMetaDataBufferingWebResponse) {
> IMetaDataBufferingWebResponse bufferingWebResponse = (IMetaDataBufferingWebResponse) response;
> WebResponse originalResponse = (WebResponse) cycle
> .getOriginalResponse();
> bufferingWebResponse.writeMetaData(originalResponse);
> }
> }
> private static IRequestHandler createRequestHandler(
> Class<? extends Page> pageClass, PageParameters params) {
> return new RenderPageRequestHandler(new PageProvider(pageClass, params));
> }
> }
> When this exception is thrown from a link handler, a ConcurrentModificationException occurs with the following stack trace:
> HeaderBufferingWebResponse.addCookie(Cookie) line: 72
> BufferedWebResponse$AddCookieAction.invoke(WebResponse) line: 240
> BufferedWebResponse.writeMetaData(WebResponse) line: 75
> HeaderBufferingWebResponse.writeMetaData(WebResponse) line: 205
> NonResettingRestartException.<init>(Class<Page>, PageParameters, RequestCycle) line: 28
> LinkPage$4.onClick() line: 38
> Analysis:
> 1) HeaderBufferingWebResponse delegates #writeMetaData() to its bufferedResponse (a BufferedWebResponse instance).
> 2) BufferedWebResponse iterates its action list with the single "AddCookieAction" and invoke()s it
> 3) BufferedWebResponse$AddCookieAction.invoke does "response.addCookie(cookie)"
> 4) The addCookie is executed with this==BufferedWebResponse from 2) which modifies the action list illegally
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Closed] (WICKET-4637)
HeaderBufferingWebResponse#writeMetaData(WebResponse) throws
ConcurrentModificationException when invoked in a link handler
Posted by "Bertrand Guay-Paquet (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-4637?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Bertrand Guay-Paquet closed WICKET-4637.
----------------------------------------
> HeaderBufferingWebResponse#writeMetaData(WebResponse) throws ConcurrentModificationException when invoked in a link handler
> ---------------------------------------------------------------------------------------------------------------------------
>
> Key: WICKET-4637
> URL: https://issues.apache.org/jira/browse/WICKET-4637
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.5.7
> Reporter: Bertrand Guay-Paquet
> Labels: response
> Attachments: wicket-4637.zip, wicket-4637_2.zip
>
>
> This ticket follows from the email thread http://markmail.org/thread/uk5y4ddoopntmkgd
> I use the following ReplaceHandlerException to trigger a redirect which restarts the response but does not discard the response's meta data (e.g. cookies).
> /**
> * Response restarting exception which does not reset the header meta data.
> */
> public class NonResettingRestartException extends ReplaceHandlerException {
> public NonResettingRestartException(final Class<? extends Page> pageClass,
> final PageParameters params, final RequestCycle cycle) {
> super(createRequestHandler(pageClass, params), true);
> Response response = cycle.getResponse();
> if (response instanceof IMetaDataBufferingWebResponse) {
> IMetaDataBufferingWebResponse bufferingWebResponse = (IMetaDataBufferingWebResponse) response;
> WebResponse originalResponse = (WebResponse) cycle
> .getOriginalResponse();
> bufferingWebResponse.writeMetaData(originalResponse);
> }
> }
> private static IRequestHandler createRequestHandler(
> Class<? extends Page> pageClass, PageParameters params) {
> return new RenderPageRequestHandler(new PageProvider(pageClass, params));
> }
> }
> When this exception is thrown from a link handler, a ConcurrentModificationException occurs with the following stack trace:
> HeaderBufferingWebResponse.addCookie(Cookie) line: 72
> BufferedWebResponse$AddCookieAction.invoke(WebResponse) line: 240
> BufferedWebResponse.writeMetaData(WebResponse) line: 75
> HeaderBufferingWebResponse.writeMetaData(WebResponse) line: 205
> NonResettingRestartException.<init>(Class<Page>, PageParameters, RequestCycle) line: 28
> LinkPage$4.onClick() line: 38
> Analysis:
> 1) HeaderBufferingWebResponse delegates #writeMetaData() to its bufferedResponse (a BufferedWebResponse instance).
> 2) BufferedWebResponse iterates its action list with the single "AddCookieAction" and invoke()s it
> 3) BufferedWebResponse$AddCookieAction.invoke does "response.addCookie(cookie)"
> 4) The addCookie is executed with this==BufferedWebResponse from 2) which modifies the action list illegally
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (WICKET-4637)
HeaderBufferingWebResponse#writeMetaData(WebResponse) throws
ConcurrentModificationException when invoked in a link handler
Posted by "Bertrand Guay-Paquet (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-4637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13406554#comment-13406554 ]
Bertrand Guay-Paquet commented on WICKET-4637:
----------------------------------------------
Hi Andrea,
Thanks for pointing out the obvious! Indeed the fix is very easy in this case. I modified the exception's constructor like so:
public NonResettingRestartException(final Class<? extends Page> pageClass,
final PageParameters params, final RequestCycle cycle) {
super(createRequestHandler(pageClass, params), true);
Response response = cycle.getResponse();
if (response instanceof IMetaDataBufferingWebResponse) {
WebResponse originalResponse = (WebResponse) cycle
.getOriginalResponse();
if (originalResponse != response) {
IMetaDataBufferingWebResponse bufferingWebResponse = (IMetaDataBufferingWebResponse) response;
bufferingWebResponse.writeMetaData(originalResponse);
}
}
}
There is now a check to not do bufferingWebResponse.writeMetaData(originalResponse) if originalResponse == RequestCycle.getResponse()
Please mark this as resolved.
> HeaderBufferingWebResponse#writeMetaData(WebResponse) throws ConcurrentModificationException when invoked in a link handler
> ---------------------------------------------------------------------------------------------------------------------------
>
> Key: WICKET-4637
> URL: https://issues.apache.org/jira/browse/WICKET-4637
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.5.7
> Reporter: Bertrand Guay-Paquet
> Labels: response
> Attachments: wicket-4637.zip, wicket-4637_2.zip
>
>
> This ticket follows from the email thread http://markmail.org/thread/uk5y4ddoopntmkgd
> I use the following ReplaceHandlerException to trigger a redirect which restarts the response but does not discard the response's meta data (e.g. cookies).
> /**
> * Response restarting exception which does not reset the header meta data.
> */
> public class NonResettingRestartException extends ReplaceHandlerException {
> public NonResettingRestartException(final Class<? extends Page> pageClass,
> final PageParameters params, final RequestCycle cycle) {
> super(createRequestHandler(pageClass, params), true);
> Response response = cycle.getResponse();
> if (response instanceof IMetaDataBufferingWebResponse) {
> IMetaDataBufferingWebResponse bufferingWebResponse = (IMetaDataBufferingWebResponse) response;
> WebResponse originalResponse = (WebResponse) cycle
> .getOriginalResponse();
> bufferingWebResponse.writeMetaData(originalResponse);
> }
> }
> private static IRequestHandler createRequestHandler(
> Class<? extends Page> pageClass, PageParameters params) {
> return new RenderPageRequestHandler(new PageProvider(pageClass, params));
> }
> }
> When this exception is thrown from a link handler, a ConcurrentModificationException occurs with the following stack trace:
> HeaderBufferingWebResponse.addCookie(Cookie) line: 72
> BufferedWebResponse$AddCookieAction.invoke(WebResponse) line: 240
> BufferedWebResponse.writeMetaData(WebResponse) line: 75
> HeaderBufferingWebResponse.writeMetaData(WebResponse) line: 205
> NonResettingRestartException.<init>(Class<Page>, PageParameters, RequestCycle) line: 28
> LinkPage$4.onClick() line: 38
> Analysis:
> 1) HeaderBufferingWebResponse delegates #writeMetaData() to its bufferedResponse (a BufferedWebResponse instance).
> 2) BufferedWebResponse iterates its action list with the single "AddCookieAction" and invoke()s it
> 3) BufferedWebResponse$AddCookieAction.invoke does "response.addCookie(cookie)"
> 4) The addCookie is executed with this==BufferedWebResponse from 2) which modifies the action list illegally
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (WICKET-4637)
HeaderBufferingWebResponse#writeMetaData(WebResponse) throws
ConcurrentModificationException when invoked in a link handler
Posted by "Andrea Del Bene (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-4637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13406498#comment-13406498 ]
Andrea Del Bene commented on WICKET-4637:
-----------------------------------------
Hi Bertrand,
in your example (wicket-4637_2.zip) the original response and the current one are the same, so you are adding the same cookie twice to the request. That's why you get the ConcurrentModificationException.
> HeaderBufferingWebResponse#writeMetaData(WebResponse) throws ConcurrentModificationException when invoked in a link handler
> ---------------------------------------------------------------------------------------------------------------------------
>
> Key: WICKET-4637
> URL: https://issues.apache.org/jira/browse/WICKET-4637
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.5.7
> Reporter: Bertrand Guay-Paquet
> Labels: response
> Attachments: wicket-4637.zip, wicket-4637_2.zip
>
>
> This ticket follows from the email thread http://markmail.org/thread/uk5y4ddoopntmkgd
> I use the following ReplaceHandlerException to trigger a redirect which restarts the response but does not discard the response's meta data (e.g. cookies).
> /**
> * Response restarting exception which does not reset the header meta data.
> */
> public class NonResettingRestartException extends ReplaceHandlerException {
> public NonResettingRestartException(final Class<? extends Page> pageClass,
> final PageParameters params, final RequestCycle cycle) {
> super(createRequestHandler(pageClass, params), true);
> Response response = cycle.getResponse();
> if (response instanceof IMetaDataBufferingWebResponse) {
> IMetaDataBufferingWebResponse bufferingWebResponse = (IMetaDataBufferingWebResponse) response;
> WebResponse originalResponse = (WebResponse) cycle
> .getOriginalResponse();
> bufferingWebResponse.writeMetaData(originalResponse);
> }
> }
> private static IRequestHandler createRequestHandler(
> Class<? extends Page> pageClass, PageParameters params) {
> return new RenderPageRequestHandler(new PageProvider(pageClass, params));
> }
> }
> When this exception is thrown from a link handler, a ConcurrentModificationException occurs with the following stack trace:
> HeaderBufferingWebResponse.addCookie(Cookie) line: 72
> BufferedWebResponse$AddCookieAction.invoke(WebResponse) line: 240
> BufferedWebResponse.writeMetaData(WebResponse) line: 75
> HeaderBufferingWebResponse.writeMetaData(WebResponse) line: 205
> NonResettingRestartException.<init>(Class<Page>, PageParameters, RequestCycle) line: 28
> LinkPage$4.onClick() line: 38
> Analysis:
> 1) HeaderBufferingWebResponse delegates #writeMetaData() to its bufferedResponse (a BufferedWebResponse instance).
> 2) BufferedWebResponse iterates its action list with the single "AddCookieAction" and invoke()s it
> 3) BufferedWebResponse$AddCookieAction.invoke does "response.addCookie(cookie)"
> 4) The addCookie is executed with this==BufferedWebResponse from 2) which modifies the action list illegally
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Comment Edited] (WICKET-4637)
HeaderBufferingWebResponse#writeMetaData(WebResponse) throws
ConcurrentModificationException when invoked in a link handler
Posted by "Andrea Del Bene (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-4637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13406498#comment-13406498 ]
Andrea Del Bene edited comment on WICKET-4637 at 7/4/12 1:17 PM:
-----------------------------------------------------------------
Hi Bertrand,
in your example (wicket-4637_2.zip) the original response and the current one are the same, so you are adding the same cookie twice. That's why you get the ConcurrentModificationException.
was (Author: bitstorm):
Hi Bertrand,
in your example (wicket-4637_2.zip) the original response and the current one are the same, so you are adding the same cookie twice to the response. That's why you get the ConcurrentModificationException.
> HeaderBufferingWebResponse#writeMetaData(WebResponse) throws ConcurrentModificationException when invoked in a link handler
> ---------------------------------------------------------------------------------------------------------------------------
>
> Key: WICKET-4637
> URL: https://issues.apache.org/jira/browse/WICKET-4637
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.5.7
> Reporter: Bertrand Guay-Paquet
> Labels: response
> Attachments: wicket-4637.zip, wicket-4637_2.zip
>
>
> This ticket follows from the email thread http://markmail.org/thread/uk5y4ddoopntmkgd
> I use the following ReplaceHandlerException to trigger a redirect which restarts the response but does not discard the response's meta data (e.g. cookies).
> /**
> * Response restarting exception which does not reset the header meta data.
> */
> public class NonResettingRestartException extends ReplaceHandlerException {
> public NonResettingRestartException(final Class<? extends Page> pageClass,
> final PageParameters params, final RequestCycle cycle) {
> super(createRequestHandler(pageClass, params), true);
> Response response = cycle.getResponse();
> if (response instanceof IMetaDataBufferingWebResponse) {
> IMetaDataBufferingWebResponse bufferingWebResponse = (IMetaDataBufferingWebResponse) response;
> WebResponse originalResponse = (WebResponse) cycle
> .getOriginalResponse();
> bufferingWebResponse.writeMetaData(originalResponse);
> }
> }
> private static IRequestHandler createRequestHandler(
> Class<? extends Page> pageClass, PageParameters params) {
> return new RenderPageRequestHandler(new PageProvider(pageClass, params));
> }
> }
> When this exception is thrown from a link handler, a ConcurrentModificationException occurs with the following stack trace:
> HeaderBufferingWebResponse.addCookie(Cookie) line: 72
> BufferedWebResponse$AddCookieAction.invoke(WebResponse) line: 240
> BufferedWebResponse.writeMetaData(WebResponse) line: 75
> HeaderBufferingWebResponse.writeMetaData(WebResponse) line: 205
> NonResettingRestartException.<init>(Class<Page>, PageParameters, RequestCycle) line: 28
> LinkPage$4.onClick() line: 38
> Analysis:
> 1) HeaderBufferingWebResponse delegates #writeMetaData() to its bufferedResponse (a BufferedWebResponse instance).
> 2) BufferedWebResponse iterates its action list with the single "AddCookieAction" and invoke()s it
> 3) BufferedWebResponse$AddCookieAction.invoke does "response.addCookie(cookie)"
> 4) The addCookie is executed with this==BufferedWebResponse from 2) which modifies the action list illegally
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (WICKET-4637)
HeaderBufferingWebResponse#writeMetaData(WebResponse) throws
ConcurrentModificationException when invoked in a link handler
Posted by "Bertrand Guay-Paquet (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-4637?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Bertrand Guay-Paquet updated WICKET-4637:
-----------------------------------------
Attachment: wicket-4637.zip
Set of test pages to test the different ways to redirect to a page from a page constructor, a link handler and a form submit handler. They all set a cookie and a session message to validate the behaviors
> HeaderBufferingWebResponse#writeMetaData(WebResponse) throws ConcurrentModificationException when invoked in a link handler
> ---------------------------------------------------------------------------------------------------------------------------
>
> Key: WICKET-4637
> URL: https://issues.apache.org/jira/browse/WICKET-4637
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.5.7
> Reporter: Bertrand Guay-Paquet
> Labels: response
> Attachments: wicket-4637.zip
>
>
> This ticket follows from the email thread http://markmail.org/thread/uk5y4ddoopntmkgd
> I use the following ReplaceHandlerException to trigger a redirect which restarts the response but does not discard the response's meta data (e.g. cookies).
> /**
> * Response restarting exception which does not reset the header meta data.
> */
> public class NonResettingRestartException extends ReplaceHandlerException {
> public NonResettingRestartException(final Class<? extends Page> pageClass,
> final PageParameters params, final RequestCycle cycle) {
> super(createRequestHandler(pageClass, params), true);
> Response response = cycle.getResponse();
> if (response instanceof IMetaDataBufferingWebResponse) {
> IMetaDataBufferingWebResponse bufferingWebResponse = (IMetaDataBufferingWebResponse) response;
> WebResponse originalResponse = (WebResponse) cycle
> .getOriginalResponse();
> bufferingWebResponse.writeMetaData(originalResponse);
> }
> }
> private static IRequestHandler createRequestHandler(
> Class<? extends Page> pageClass, PageParameters params) {
> return new RenderPageRequestHandler(new PageProvider(pageClass, params));
> }
> }
> When this exception is thrown from a link handler, a ConcurrentModificationException occurs with the following stack trace:
> HeaderBufferingWebResponse.addCookie(Cookie) line: 72
> BufferedWebResponse$AddCookieAction.invoke(WebResponse) line: 240
> BufferedWebResponse.writeMetaData(WebResponse) line: 75
> HeaderBufferingWebResponse.writeMetaData(WebResponse) line: 205
> NonResettingRestartException.<init>(Class<Page>, PageParameters, RequestCycle) line: 28
> LinkPage$4.onClick() line: 38
> Analysis:
> 1) HeaderBufferingWebResponse delegates #writeMetaData() to its bufferedResponse (a BufferedWebResponse instance).
> 2) BufferedWebResponse iterates its action list with the single "AddCookieAction" and invoke()s it
> 3) BufferedWebResponse$AddCookieAction.invoke does "response.addCookie(cookie)"
> 4) The addCookie is executed with this==BufferedWebResponse from 2) which modifies the action list illegally
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Comment Edited] (WICKET-4637)
HeaderBufferingWebResponse#writeMetaData(WebResponse) throws
ConcurrentModificationException when invoked in a link handler
Posted by "Andrea Del Bene (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-4637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13406498#comment-13406498 ]
Andrea Del Bene edited comment on WICKET-4637 at 7/4/12 1:16 PM:
-----------------------------------------------------------------
Hi Bertrand,
in your example (wicket-4637_2.zip) the original response and the current one are the same, so you are adding the same cookie twice to the response. That's why you get the ConcurrentModificationException.
was (Author: bitstorm):
Hi Bertrand,
in your example (wicket-4637_2.zip) the original response and the current one are the same, so you are adding the same cookie twice to the request. That's why you get the ConcurrentModificationException.
> HeaderBufferingWebResponse#writeMetaData(WebResponse) throws ConcurrentModificationException when invoked in a link handler
> ---------------------------------------------------------------------------------------------------------------------------
>
> Key: WICKET-4637
> URL: https://issues.apache.org/jira/browse/WICKET-4637
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.5.7
> Reporter: Bertrand Guay-Paquet
> Labels: response
> Attachments: wicket-4637.zip, wicket-4637_2.zip
>
>
> This ticket follows from the email thread http://markmail.org/thread/uk5y4ddoopntmkgd
> I use the following ReplaceHandlerException to trigger a redirect which restarts the response but does not discard the response's meta data (e.g. cookies).
> /**
> * Response restarting exception which does not reset the header meta data.
> */
> public class NonResettingRestartException extends ReplaceHandlerException {
> public NonResettingRestartException(final Class<? extends Page> pageClass,
> final PageParameters params, final RequestCycle cycle) {
> super(createRequestHandler(pageClass, params), true);
> Response response = cycle.getResponse();
> if (response instanceof IMetaDataBufferingWebResponse) {
> IMetaDataBufferingWebResponse bufferingWebResponse = (IMetaDataBufferingWebResponse) response;
> WebResponse originalResponse = (WebResponse) cycle
> .getOriginalResponse();
> bufferingWebResponse.writeMetaData(originalResponse);
> }
> }
> private static IRequestHandler createRequestHandler(
> Class<? extends Page> pageClass, PageParameters params) {
> return new RenderPageRequestHandler(new PageProvider(pageClass, params));
> }
> }
> When this exception is thrown from a link handler, a ConcurrentModificationException occurs with the following stack trace:
> HeaderBufferingWebResponse.addCookie(Cookie) line: 72
> BufferedWebResponse$AddCookieAction.invoke(WebResponse) line: 240
> BufferedWebResponse.writeMetaData(WebResponse) line: 75
> HeaderBufferingWebResponse.writeMetaData(WebResponse) line: 205
> NonResettingRestartException.<init>(Class<Page>, PageParameters, RequestCycle) line: 28
> LinkPage$4.onClick() line: 38
> Analysis:
> 1) HeaderBufferingWebResponse delegates #writeMetaData() to its bufferedResponse (a BufferedWebResponse instance).
> 2) BufferedWebResponse iterates its action list with the single "AddCookieAction" and invoke()s it
> 3) BufferedWebResponse$AddCookieAction.invoke does "response.addCookie(cookie)"
> 4) The addCookie is executed with this==BufferedWebResponse from 2) which modifies the action list illegally
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (WICKET-4637)
HeaderBufferingWebResponse#writeMetaData(WebResponse) throws
ConcurrentModificationException when invoked in a link handler
Posted by "Bertrand Guay-Paquet (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-4637?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Bertrand Guay-Paquet updated WICKET-4637:
-----------------------------------------
Attachment: wicket-4637_2.zip
Small fix to the report messages...
> HeaderBufferingWebResponse#writeMetaData(WebResponse) throws ConcurrentModificationException when invoked in a link handler
> ---------------------------------------------------------------------------------------------------------------------------
>
> Key: WICKET-4637
> URL: https://issues.apache.org/jira/browse/WICKET-4637
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.5.7
> Reporter: Bertrand Guay-Paquet
> Labels: response
> Attachments: wicket-4637.zip, wicket-4637_2.zip
>
>
> This ticket follows from the email thread http://markmail.org/thread/uk5y4ddoopntmkgd
> I use the following ReplaceHandlerException to trigger a redirect which restarts the response but does not discard the response's meta data (e.g. cookies).
> /**
> * Response restarting exception which does not reset the header meta data.
> */
> public class NonResettingRestartException extends ReplaceHandlerException {
> public NonResettingRestartException(final Class<? extends Page> pageClass,
> final PageParameters params, final RequestCycle cycle) {
> super(createRequestHandler(pageClass, params), true);
> Response response = cycle.getResponse();
> if (response instanceof IMetaDataBufferingWebResponse) {
> IMetaDataBufferingWebResponse bufferingWebResponse = (IMetaDataBufferingWebResponse) response;
> WebResponse originalResponse = (WebResponse) cycle
> .getOriginalResponse();
> bufferingWebResponse.writeMetaData(originalResponse);
> }
> }
> private static IRequestHandler createRequestHandler(
> Class<? extends Page> pageClass, PageParameters params) {
> return new RenderPageRequestHandler(new PageProvider(pageClass, params));
> }
> }
> When this exception is thrown from a link handler, a ConcurrentModificationException occurs with the following stack trace:
> HeaderBufferingWebResponse.addCookie(Cookie) line: 72
> BufferedWebResponse$AddCookieAction.invoke(WebResponse) line: 240
> BufferedWebResponse.writeMetaData(WebResponse) line: 75
> HeaderBufferingWebResponse.writeMetaData(WebResponse) line: 205
> NonResettingRestartException.<init>(Class<Page>, PageParameters, RequestCycle) line: 28
> LinkPage$4.onClick() line: 38
> Analysis:
> 1) HeaderBufferingWebResponse delegates #writeMetaData() to its bufferedResponse (a BufferedWebResponse instance).
> 2) BufferedWebResponse iterates its action list with the single "AddCookieAction" and invoke()s it
> 3) BufferedWebResponse$AddCookieAction.invoke does "response.addCookie(cookie)"
> 4) The addCookie is executed with this==BufferedWebResponse from 2) which modifies the action list illegally
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (WICKET-4637)
HeaderBufferingWebResponse#writeMetaData(WebResponse) throws
ConcurrentModificationException when invoked in a link handler
Posted by "Martin Grigorov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-4637?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Martin Grigorov resolved WICKET-4637.
-------------------------------------
Resolution: Not A Problem
Closing as 'Not a problem'.
Thank you, guys!
> HeaderBufferingWebResponse#writeMetaData(WebResponse) throws ConcurrentModificationException when invoked in a link handler
> ---------------------------------------------------------------------------------------------------------------------------
>
> Key: WICKET-4637
> URL: https://issues.apache.org/jira/browse/WICKET-4637
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.5.7
> Reporter: Bertrand Guay-Paquet
> Labels: response
> Attachments: wicket-4637.zip, wicket-4637_2.zip
>
>
> This ticket follows from the email thread http://markmail.org/thread/uk5y4ddoopntmkgd
> I use the following ReplaceHandlerException to trigger a redirect which restarts the response but does not discard the response's meta data (e.g. cookies).
> /**
> * Response restarting exception which does not reset the header meta data.
> */
> public class NonResettingRestartException extends ReplaceHandlerException {
> public NonResettingRestartException(final Class<? extends Page> pageClass,
> final PageParameters params, final RequestCycle cycle) {
> super(createRequestHandler(pageClass, params), true);
> Response response = cycle.getResponse();
> if (response instanceof IMetaDataBufferingWebResponse) {
> IMetaDataBufferingWebResponse bufferingWebResponse = (IMetaDataBufferingWebResponse) response;
> WebResponse originalResponse = (WebResponse) cycle
> .getOriginalResponse();
> bufferingWebResponse.writeMetaData(originalResponse);
> }
> }
> private static IRequestHandler createRequestHandler(
> Class<? extends Page> pageClass, PageParameters params) {
> return new RenderPageRequestHandler(new PageProvider(pageClass, params));
> }
> }
> When this exception is thrown from a link handler, a ConcurrentModificationException occurs with the following stack trace:
> HeaderBufferingWebResponse.addCookie(Cookie) line: 72
> BufferedWebResponse$AddCookieAction.invoke(WebResponse) line: 240
> BufferedWebResponse.writeMetaData(WebResponse) line: 75
> HeaderBufferingWebResponse.writeMetaData(WebResponse) line: 205
> NonResettingRestartException.<init>(Class<Page>, PageParameters, RequestCycle) line: 28
> LinkPage$4.onClick() line: 38
> Analysis:
> 1) HeaderBufferingWebResponse delegates #writeMetaData() to its bufferedResponse (a BufferedWebResponse instance).
> 2) BufferedWebResponse iterates its action list with the single "AddCookieAction" and invoke()s it
> 3) BufferedWebResponse$AddCookieAction.invoke does "response.addCookie(cookie)"
> 4) The addCookie is executed with this==BufferedWebResponse from 2) which modifies the action list illegally
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira