Buggy code:
public abstract class MarkupContainer extends Component { private static final long serialVersionUID = 1L ; private static final Logger log = LoggerFactory . getLogger ( MarkupContainer . class ) ; private Object children ; private transient MarkupStream markupStream ; public MarkupContainer ( final String id ) { } public MarkupContainer ( final String id , IModel model ) { } public final MarkupContainer add ( final Component child ) { } public final MarkupContainer addOrReplace ( final Component child ) { } public final boolean autoAdd ( final Component component , final MarkupStream markupStream ) { } public final boolean autoAdd ( final Component component ) { } public final boolean contains ( final Component component , final boolean recurse ) { } public final Component get ( final String path ) { } public MarkupStream getAssociatedMarkupStream ( final boolean throwException ) { } public final MarkupStream getMarkupStream ( ) { } public String getMarkupType ( ) { } public void internalAdd ( final Component child ) { } public boolean isTransparentResolver ( ) { } public final Iterator iterator ( ) { } public final Iterator iterator ( Comparator comparator ) { } public final IResourceStream newMarkupResourceStream ( Class containerClass ) { } public void remove ( final Component component ) { } public final void remove ( final String id ) { } public final void removeAll ( ) { } public final void renderAssociatedMarkup ( final String openTagName , final String exceptionMessage ) { } public final MarkupContainer replace ( final Component child ) { } public Component setModel ( final IModel model ) { <START_BUG> final IModel previous = this . model ; <END_BUG> super . setModel ( model ) ; if ( previous instanceof IComponentInheritedModel ) { visitChildren ( new IVisitor ( ) { public Object component ( Component component ) { IModel compModel = component . getModel ( ) ; if ( compModel instanceof IWrapModel ) { compModel = ( ( IWrapModel ) ( compModel ) ) . getWrappedModel ( ) ; } if ( compModel == previous ) { component . setModel ( null ) ; } else if ( compModel == model ) { component . modelChanged ( ) ; } return IVisitor . CONTINUE_TRAVERSAL ; } } ) ; } return this ; } public final int size ( ) { } public String toString ( ) { } public String toString ( final boolean detailed ) { } public final Object visitChildren ( final Class clazz , final IVisitor visitor ) { } public final Object visitChildren ( final IVisitor visitor ) { } private final void addedComponent ( final Component component ) { } private final void children_add ( final Component child ) { } private final Component children_get ( int index ) { } private final Object postprocess ( Object object , boolean reconstruct , MarkupContainer parent , int index ) { } private final Object children_get ( int index , boolean reconstruct ) { } private final String getId ( Object object ) { } private final Component children_get ( final String id ) { } private final int children_indexOf ( Component child ) { } private final Component children_remove ( Component component ) { } private final Component children_remove ( int index ) { } private final Object children_set ( int index , Object child , boolean reconstruct ) { } private final Component children_set ( int index , Component child ) { } private final int children_size ( ) { } private final Component put ( final Component child ) { } private final void removedComponent ( final Component component ) { } private final void renderNext ( final MarkupStream markupStream ) { } protected final MarkupStream findMarkupStream ( ) { } protected void onComponentTagBody ( final MarkupStream markupStream , final ComponentTag openTag ) { } protected void onRender ( final MarkupStream markupStream ) { } protected void renderAll ( final MarkupStream markupStream ) { } protected final void renderComponentTagBody ( final MarkupStream markupStream , final ComponentTag openTag ) { } protected final void setMarkupStream ( final MarkupStream markupStream ) { } private static class ComponentSourceEntry extends org . apache . wicket . ComponentSourceEntry { private ComponentSourceEntry ( MarkupContainer container , Component component , IComponentSource componentSource ) { } private static final long serialVersionUID = 1L ; protected void setChild ( MarkupContainer parent , int index , Component child ) { } } void detachChildren ( ) { } void internalMarkRendering ( ) { } private Component [ ] copyChildren ( ) { } void onBeforeRenderChildren ( ) { } void onAfterRenderChildren ( ) { } public boolean hasAssociatedMarkup ( ) { } void setRenderAllowed ( ) { } }

Fix:
final IModel previous = getModelImpl ( ) ;