Buggy code:
public class AjaxRequestTarget implements IRequestTarget { public static interface IListener { public void onBeforeRespond ( Map < String , Component > map , AjaxRequestTarget target ) { } public void onAfterRespond ( Map < String , Component > map , AjaxRequestTarget . IJavascriptResponse response ) { } } public static interface IJavascriptResponse { public void addJavascript ( String script ) { } } private static final Logger Log = LoggerFactory . getLogger ( AjaxRequestTarget . class ) ; private final List < String > appendJavascripts = new ArrayList < String > ( ) ; private final List < String > prependJavascripts = new ArrayList < String > ( ) ; private final Map < String , Component > markupIdToComponent = new LinkedHashMap < String , Component > ( ) ; private List < AjaxRequestTarget . IListener > listeners = null ; public AjaxRequestTarget ( ) { } public void addListener ( AjaxRequestTarget . IListener listener ) { } public final void addComponent ( Component component ) { } public final void addComponent ( Component component , String markupId ) { } public final void appendJavascript ( String javascript ) { } public void detach ( final RequestCycle requestCycle ) { } @ Override public boolean equals ( final Object obj ) { } @ Override public int hashCode ( ) { } public final void prependJavascript ( String javascript ) { } public final void respond ( final RequestCycle requestCycle ) { } private void fireOnBeforeRespondListeners ( ) { } private void fireOnAfterRespondListeners ( final WebResponse response ) { } @ SuppressWarnings ( "unchecked" ) private void respondComponents ( WebResponse response ) { } @ Override public String toString ( ) { } protected String encode ( String str ) { } protected String getEncodingName ( ) { } protected boolean needsEncoding ( String str ) { } private void respondComponent ( final Response response , final String markupId , final Component component ) { } private class AjaxHeaderResponse extends HeaderResponse { private static final long serialVersionUID = 1L ; public AjaxHeaderResponse ( Response response ) { } @ Override public void renderOnDomReadyJavascript ( String javascript ) { } @ Override public void renderOnLoadJavascript ( String javascript ) { } } private void respondHeaderContribution ( final Response response , final Component component ) { Response encodingResponse = new StringResponse ( ) ; try { final IHeaderResponse headerResponse = new AjaxRequestTarget . AjaxHeaderResponse ( encodingResponse ) ; RequestCycle . get ( ) . setResponse ( headerResponse . getResponse ( ) ) ; <START_BUG> component . renderHead ( headerResponse ) ; <END_BUG> } finally { RequestCycle . get ( ) . setResponse ( response ) ; } String data = encodingResponse . toString ( ) ; if ( ( data . length ( ) ) != 0 ) { response . write ( "<header-contribution" ) ; if ( needsEncoding ( encodingResponse . toString ( ) ) ) { response . write ( "<seq2seq4repair_space>encoding=\"" ) ; response . write ( getEncodingName ( ) ) ; response . write ( "\"<seq2seq4repair_space>" ) ; data = encode ( data ) ; } response . write ( "><![CDATA[<head<seq2seq4repair_space>xmlns:wicket=\"http:////wicket.sourceforge.net\">" ) ; response . write ( data ) ; response . write ( "<//head>]]>" ) ; response . write ( "<//header-contribution>" ) ; } } private void respondInvocation ( final Response response , final String js ) { } }

Fix:
component . internalRenderHead ( headerResponse ) ;