Buggy code:
public class AttributeGroup extends org . tigris . scarab . om . BaseAttributeGroup implements Persistent { public static final String GET_ATTRIBUTES = "getAttributes" ; private static final String GET_R_ATTRIBUTE_ATTRGROUP = "getRAttributeAttributeGroup" ; public boolean isGlobal ( ) throws TorqueException { } public ScarabModule getScarabModule ( ) { } public void setScarabModule ( ScarabModule module ) { } public void setModule ( Module me ) throws TorqueException { } public Module getModule ( ) throws TorqueException { } private static MethodResultCache getMethodResult ( ) { } public boolean hasAnyOptionAttributes ( ) throws Exception { } public List getAttributes ( ) throws Exception { } public boolean hasAttribute ( Attribute attribute ) throws Exception { } public int getHighestOrderedAttribute ( ) throws Exception { } public RAttributeAttributeGroup getRAttributeAttributeGroup ( Attribute attribute ) throws Exception { } public void delete ( ScarabUser user , Module module ) throws Exception { String permission = null ; int dupeSequence = 0 ; if ( isGlobal ( ) ) { permission = ScarabSecurity . DOMAIN__EDIT ; } else { permission = ScarabSecurity . MODULE__CONFIGURE ; } if ( user . hasPermission ( permission , module ) ) { IssueType issueType = IssueTypeManager . getInstance ( SimpleKey . keyFor ( getIssueTypeId ( ) ) , false ) ; if ( issueType . getLocked ( ) ) { throw new ScarabException ( ( "You<seq2seq4repair_space>cannot<seq2seq4repair_space>delete<seq2seq4repair_space>this<seq2seq4repair_space>group,<seq2seq4repair_space>" + "because<seq2seq4repair_space>this<seq2seq4repair_space>issue<seq2seq4repair_space>type<seq2seq4repair_space>is<seq2seq4repair_space>locked." ) ) ; } else { List attrGroups = null ; if ( isGlobal ( ) ) { attrGroups = issueType . getAttributeGroups ( false ) ; dupeSequence = issueType . getDedupeSequence ( ) ; Criteria crit = new Criteria ( ) . addJoin ( ATTRIBUTE_ID , RAttributeAttributeGroupPeer . ATTRIBUTE_ID ) . add ( GROUP_ID , getAttributeGroupId ( ) ) ; List results = RIssueTypeAttributePeer . doSelect ( crit ) ; for ( int i = 0 ; i < ( results . size ( ) ) ; i ++ ) { RIssueTypeAttribute ria = ( ( RIssueTypeAttribute ) ( results . get ( i ) ) ) ; ria . delete ( user ) ; } } else { attrGroups = module . getAttributeGroups ( getIssueType ( ) , false ) ; dupeSequence = module . getDedupeSequence ( issueType ) ; Criteria crit = new Criteria ( ) . addJoin ( RModuleAttributePeer . ATTRIBUTE_ID , RAttributeAttributeGroupPeer . ATTRIBUTE_ID ) . add ( GROUP_ID , getAttributeGroupId ( ) ) . add ( MODULE_ID , getModuleId ( ) ) ; Criteria . Criterion critIssueType = crit . getNewCriterion ( ISSUE_TYPE_ID , getIssueTypeId ( ) , EQUAL ) ; critIssueType . or ( crit . getNewCriterion ( ISSUE_TYPE_ID , issueType . getTemplateId ( ) , EQUAL ) ) ; crit . and ( critIssueType ) ; List results = RModuleAttributePeer . doSelect ( crit ) ; for ( int i = 0 ; i < ( results . size ( ) ) ; i ++ ) { RModuleAttribute rma = ( ( RModuleAttribute ) ( results . get ( i ) ) ) ; rma . delete ( ) ; } } Criteria crit2 = new Criteria ( ) . add ( GROUP_ID , getAttributeGroupId ( ) ) ; RAttributeAttributeGroupPeer . doDelete ( crit2 ) ; int order = getOrder ( ) ; crit2 = new Criteria ( ) . add ( ATTRIBUTE_GROUP_ID , getAttributeGroupId ( ) ) ; AttributeGroupPeer . doDelete ( crit2 ) ; IssueTypeManager . getManager ( ) . refreshedObject ( this ) ; for ( int i = 0 ; i < ( attrGroups . size ( ) ) ; i ++ ) { AttributeGroup tempGroup = ( ( AttributeGroup ) ( attrGroups . get ( i ) ) ) ; int tempOrder = tempGroup . getOrder ( ) ; if ( ( tempGroup . getOrder ( ) ) > order ) { <START_BUG> if ( tempOrder == ( dupeSequence + 1 ) ) { <END_BUG> tempGroup . setOrder ( ( tempOrder - 2 ) ) ; } else { tempGroup . setOrder ( ( tempOrder - 1 ) ) ; } tempGroup . save ( ) ; } } } ScarabCache . clear ( ) ; } else { throw new ScarabException ( ScarabConstants . NO_PERMISSION_MESSAGE ) ; } } public void addAttribute ( Attribute attribute ) throws Exception { } public void deleteAttribute ( Attribute attribute , ScarabUser user , Module module ) throws Exception { } private RAttributeAttributeGroup addRAttributeAttributeGroup ( Attribute attribute ) throws Exception { } public AttributeGroup copyGroup ( ) throws Exception { } }

Fix:
if ( ( tempOrder == ( dupeSequence + 1 ) ) && ( tempOrder == 3 ) ) {