Program: 60459
Project: 60459
Buggy source:
public Ownership(final GroupWrapper groupWrapper,final PageReference pageRef){
  super();
  this.wrapper=groupWrapper;
  isGroupOwnership=Model.of(groupWrapper.getInnerObject().getGroupOwner() != null);
  final BootstrapToggleConfig config=new BootstrapToggleConfig().withOnStyle(BootstrapToggleConfig.Style.info).withOffStyle(BootstrapToggleConfig.Style.warning).withSize(BootstrapToggleConfig.Size.mini);
  add(new BootstrapToggle("String_Node_Str",new Model<Boolean>(){
    private static final long serialVersionUID=6062041315055645807L;
    @Override public Boolean getObject(){
      return isGroupOwnership.getObject();
    }
  }
,config){
    private static final long serialVersionUID=2969634208049189343L;
    @Override protected IModel<String> getOffLabel(){
      return Model.of("String_Node_Str");
    }
    @Override protected IModel<String> getOnLabel(){
      return Model.of("String_Node_Str");
    }
    @Override protected CheckBox newCheckBox(    final String id,    final IModel<Boolean> model){
      final CheckBox checkBox=super.newCheckBox(id,model);
      checkBox.add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE){
        private static final long serialVersionUID=1L;
        @Override protected void onUpdate(        final AjaxRequestTarget target){
          isGroupOwnership.setObject(!isGroupOwnership.getObject());
          if (isGroupOwnership.getObject()) {
            ownerContainer.addOrReplace(groupSearchFragment);
            groupDirectoryPanel.search(null,target);
          }
 else {
            ownerContainer.addOrReplace(userSearchFragment);
            userDirectoryPanel.search(null,target);
          }
          target.add(ownerContainer);
        }
      }
);
      return checkBox;
    }
  }
);
  ownerContainer=new WebMarkupContainer("String_Node_Str");
  ownerContainer.setOutputMarkupId(true);
  this.add(ownerContainer);
  groupSearchFragment=new Fragment("String_Node_Str","String_Node_Str",this);
  groupSearchPanel=new GroupSearchPanel.Builder(new ListModel<>(new ArrayList<SearchClause>())).required(false).enableSearch().build("String_Node_Str");
  groupSearchFragment.add(groupSearchPanel.setRenderBodyOnly(true));
  AnyTypeTO anyTypeTO=anyTypeRestClient.read(AnyTypeKind.GROUP.name());
  groupDirectoryPanel=GroupSelectionDirectoryPanel.class.cast(new GroupSelectionDirectoryPanel.Builder(anyTypeClassRestClient.list(anyTypeTO.getClasses()),anyTypeTO.getKey(),pageRef).build("String_Node_Str"));
  groupSearchFragment.add(groupDirectoryPanel);
  userSearchFragment=new Fragment("String_Node_Str","String_Node_Str",this);
  userSearchPanel=UserSearchPanel.class.cast(new UserSearchPanel.Builder(new ListModel<>(new ArrayList<SearchClause>())).required(false).enableSearch().build("String_Node_Str"));
  userSearchFragment.add(userSearchPanel.setRenderBodyOnly(true));
  anyTypeTO=anyTypeRestClient.read(AnyTypeKind.USER.name());
  userDirectoryPanel=UserSelectionDirectoryPanel.class.cast(new UserSelectionDirectoryPanel.Builder(anyTypeClassRestClient.list(anyTypeTO.getClasses()),anyTypeTO.getKey(),pageRef).build("String_Node_Str"));
  userSearchFragment.add(userDirectoryPanel);
  if (isGroupOwnership.getObject()) {
    ownerContainer.add(groupSearchFragment);
  }
 else {
    ownerContainer.add(userSearchFragment);
  }
  final AjaxTextFieldPanel userOwner=new AjaxTextFieldPanel("String_Node_Str","String_Node_Str",new PropertyModel<String>(groupWrapper.getInnerObject(),"String_Node_Str"){
    private static final long serialVersionUID=-3743432456095828573L;
    @Override public String getObject(){
      if (groupWrapper.getInnerObject().getUserOwner() == null) {
        return StringUtils.EMPTY;
      }
 else {
        UserTO userTO=userRestClient.read(groupWrapper.getInnerObject().getUserOwner());
        if (userTO == null) {
          return StringUtils.EMPTY;
        }
 else {
          return String.format("String_Node_Str",userTO.getKey(),userTO.getUsername());
        }
      }
    }
    @Override public void setObject(    final String object){
      if (StringUtils.isBlank(object)) {
        groupWrapper.getInnerObject().setUserOwner(null);
      }
 else {
        final Matcher matcher=owner.matcher(object);
        if (matcher.matches()) {
          groupWrapper.getInnerObject().setUserOwner(matcher.group(1));
        }
      }
    }
  }
,false);
  userOwner.setPlaceholder("String_Node_Str");
  userOwner.hideLabel();
  userOwner.setReadOnly(true).setOutputMarkupId(true);
  userSearchFragment.add(userOwner);
  final IndicatingAjaxLink<Void> userOwnerReset=new IndicatingAjaxLink<Void>("String_Node_Str"){
    private static final long serialVersionUID=-7978723352517770644L;
    @Override public void onClick(    final AjaxRequestTarget target){
      send(Ownership.this,Broadcast.EXACT,new GroupSelectionDirectoryPanel.ItemSelection<GroupTO>(target,null));
    }
  }
;
  userSearchFragment.add(userOwnerReset);
  final AjaxTextFieldPanel groupOwner=new AjaxTextFieldPanel("String_Node_Str","String_Node_Str",new PropertyModel<String>(groupWrapper.getInnerObject(),"String_Node_Str"){
    private static final long serialVersionUID=-3743432456095828573L;
    @Override public String getObject(){
      if (groupWrapper.getInnerObject().getGroupOwner() == null) {
        return StringUtils.EMPTY;
      }
 else {
        GroupTO groupTO=groupRestClient.read(groupWrapper.getInnerObject().getGroupOwner());
        if (groupTO == null) {
          return StringUtils.EMPTY;
        }
 else {
          return String.format("String_Node_Str",groupTO.getKey(),groupTO.getName());
        }
      }
    }
    @Override public void setObject(    final String object){
      if (StringUtils.isBlank(object)) {
        groupWrapper.getInnerObject().setGroupOwner(null);
      }
 else {
        final Matcher matcher=owner.matcher(object);
        if (matcher.matches()) {
          groupWrapper.getInnerObject().setGroupOwner(matcher.group(1));
        }
      }
    }
  }
,false);
  groupOwner.setPlaceholder("String_Node_Str");
  groupOwner.hideLabel();
  groupOwner.setReadOnly(true).setOutputMarkupId(true);
  groupSearchFragment.add(groupOwner);
  final IndicatingAjaxLink<Void> groupOwnerReset=new IndicatingAjaxLink<Void>("String_Node_Str"){
    private static final long serialVersionUID=-7978723352517770644L;
    @Override public void onClick(    final AjaxRequestTarget target){
      send(Ownership.this,Broadcast.EXACT,new GroupSelectionDirectoryPanel.ItemSelection<GroupTO>(target,null));
    }
  }
;
  groupSearchFragment.add(groupOwnerReset);
}

Fixed version (ground truth):
public Ownership(final GroupWrapper groupWrapper,final PageReference pageRef){
  super();
  setTitleModel(new ResourceModel("String_Node_Str"));
  this.wrapper=groupWrapper;
  isGroupOwnership=Model.of(groupWrapper.getInnerObject().getGroupOwner() != null);
  final BootstrapToggleConfig config=new BootstrapToggleConfig().withOnStyle(BootstrapToggleConfig.Style.info).withOffStyle(BootstrapToggleConfig.Style.warning).withSize(BootstrapToggleConfig.Size.mini);
  add(new BootstrapToggle("String_Node_Str",new Model<Boolean>(){
    private static final long serialVersionUID=6062041315055645807L;
    @Override public Boolean getObject(){
      return isGroupOwnership.getObject();
    }
  }
,config){
    private static final long serialVersionUID=2969634208049189343L;
    @Override protected IModel<String> getOffLabel(){
      return Model.of("String_Node_Str");
    }
    @Override protected IModel<String> getOnLabel(){
      return Model.of("String_Node_Str");
    }
    @Override protected CheckBox newCheckBox(    final String id,    final IModel<Boolean> model){
      final CheckBox checkBox=super.newCheckBox(id,model);
      checkBox.add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE){
        private static final long serialVersionUID=1L;
        @Override protected void onUpdate(        final AjaxRequestTarget target){
          isGroupOwnership.setObject(!isGroupOwnership.getObject());
          if (isGroupOwnership.getObject()) {
            ownerContainer.addOrReplace(groupSearchFragment);
            groupDirectoryPanel.search(null,target);
          }
 else {
            ownerContainer.addOrReplace(userSearchFragment);
            userDirectoryPanel.search(null,target);
          }
          target.add(ownerContainer);
        }
      }
);
      return checkBox;
    }
  }
);
  ownerContainer=new WebMarkupContainer("String_Node_Str");
  ownerContainer.setOutputMarkupId(true);
  this.add(ownerContainer);
  groupSearchFragment=new Fragment("String_Node_Str","String_Node_Str",this);
  groupSearchPanel=new GroupSearchPanel.Builder(new ListModel<>(new ArrayList<SearchClause>())).required(false).enableSearch().build("String_Node_Str");
  groupSearchFragment.add(groupSearchPanel.setRenderBodyOnly(true));
  AnyTypeTO anyTypeTO=anyTypeRestClient.read(AnyTypeKind.GROUP.name());
  groupDirectoryPanel=GroupSelectionDirectoryPanel.class.cast(new GroupSelectionDirectoryPanel.Builder(anyTypeClassRestClient.list(anyTypeTO.getClasses()),anyTypeTO.getKey(),pageRef).build("String_Node_Str"));
  groupSearchFragment.add(groupDirectoryPanel);
  userSearchFragment=new Fragment("String_Node_Str","String_Node_Str",this);
  userSearchPanel=UserSearchPanel.class.cast(new UserSearchPanel.Builder(new ListModel<>(new ArrayList<SearchClause>())).required(false).enableSearch().build("String_Node_Str"));
  userSearchFragment.add(userSearchPanel.setRenderBodyOnly(true));
  anyTypeTO=anyTypeRestClient.read(AnyTypeKind.USER.name());
  userDirectoryPanel=UserSelectionDirectoryPanel.class.cast(new UserSelectionDirectoryPanel.Builder(anyTypeClassRestClient.list(anyTypeTO.getClasses()),anyTypeTO.getKey(),pageRef).build("String_Node_Str"));
  userSearchFragment.add(userDirectoryPanel);
  if (isGroupOwnership.getObject()) {
    ownerContainer.add(groupSearchFragment);
  }
 else {
    ownerContainer.add(userSearchFragment);
  }
  final AjaxTextFieldPanel userOwner=new AjaxTextFieldPanel("String_Node_Str","String_Node_Str",new PropertyModel<String>(groupWrapper.getInnerObject(),"String_Node_Str"){
    private static final long serialVersionUID=-3743432456095828573L;
    @Override public String getObject(){
      if (groupWrapper.getInnerObject().getUserOwner() == null) {
        return StringUtils.EMPTY;
      }
 else {
        UserTO userTO=userRestClient.read(groupWrapper.getInnerObject().getUserOwner());
        if (userTO == null) {
          return StringUtils.EMPTY;
        }
 else {
          return String.format("String_Node_Str",userTO.getKey(),userTO.getUsername());
        }
      }
    }
    @Override public void setObject(    final String object){
      if (StringUtils.isBlank(object)) {
        groupWrapper.getInnerObject().setUserOwner(null);
      }
 else {
        final Matcher matcher=owner.matcher(object);
        if (matcher.matches()) {
          groupWrapper.getInnerObject().setUserOwner(matcher.group(1));
        }
      }
    }
  }
,false);
  userOwner.setPlaceholder("String_Node_Str");
  userOwner.hideLabel();
  userOwner.setReadOnly(true).setOutputMarkupId(true);
  userSearchFragment.add(userOwner);
  final IndicatingAjaxLink<Void> userOwnerReset=new IndicatingAjaxLink<Void>("String_Node_Str"){
    private static final long serialVersionUID=-7978723352517770644L;
    @Override public void onClick(    final AjaxRequestTarget target){
      send(Ownership.this,Broadcast.EXACT,new GroupSelectionDirectoryPanel.ItemSelection<GroupTO>(target,null));
    }
  }
;
  userSearchFragment.add(userOwnerReset);
  final AjaxTextFieldPanel groupOwner=new AjaxTextFieldPanel("String_Node_Str","String_Node_Str",new PropertyModel<String>(groupWrapper.getInnerObject(),"String_Node_Str"){
    private static final long serialVersionUID=-3743432456095828573L;
    @Override public String getObject(){
      if (groupWrapper.getInnerObject().getGroupOwner() == null) {
        return StringUtils.EMPTY;
      }
 else {
        GroupTO groupTO=groupRestClient.read(groupWrapper.getInnerObject().getGroupOwner());
        if (groupTO == null) {
          return StringUtils.EMPTY;
        }
 else {
          return String.format("String_Node_Str",groupTO.getKey(),groupTO.getName());
        }
      }
    }
    @Override public void setObject(    final String object){
      if (StringUtils.isBlank(object)) {
        groupWrapper.getInnerObject().setGroupOwner(null);
      }
 else {
        final Matcher matcher=owner.matcher(object);
        if (matcher.matches()) {
          groupWrapper.getInnerObject().setGroupOwner(matcher.group(1));
        }
      }
    }
  }
,false);
  groupOwner.setPlaceholder("String_Node_Str");
  groupOwner.hideLabel();
  groupOwner.setReadOnly(true).setOutputMarkupId(true);
  groupSearchFragment.add(groupOwner);
  final IndicatingAjaxLink<Void> groupOwnerReset=new IndicatingAjaxLink<Void>("String_Node_Str"){
    private static final long serialVersionUID=-7978723352517770644L;
    @Override public void onClick(    final AjaxRequestTarget target){
      send(Ownership.this,Broadcast.EXACT,new GroupSelectionDirectoryPanel.ItemSelection<GroupTO>(target,null));
    }
  }
;
  groupSearchFragment.add(groupOwnerReset);
}