Buggy code:
@ Autowired private ContentAssociationRepository contentAssociationRepository ; @ Autowired protected TaxonomyService taxonomyService ; @ Autowired private ResourceService resourceService ; @ Autowired private ResourceImageUtil resourceImageUtil ; @ Autowired private RevisionHistoryService revisionHistoryService ; @ Autowired private ContentService contentService ; @ Autowired private ResourceCassandraService resourceCassandraService ; @ Autowired private FeedbackService feedbackService ; @ Autowired @ Resource ( name = "resourceManager" ) private ResourceManager resourceManager ; @ Autowired private CustomTableRepository customTableRepository ; @ Autowired private MailAsyncExecutor mailAsyncExecutor ; @ Autowired private AsyncExecutor asyncExecutor ; @ Autowired private CommentRepository commentRepository ; @ Autowired private CollaboratorRepository collaboratorRepository ; @ Autowired private RedisService redisService ; @ Autowired private CustomFieldsService customFieldsService ; @ Autowired private UserRepository userRepository ; @ Autowired private OperationAuthorizer operationAuthorizer ; @ Autowired private PartyService partyService ; private String fileName ; private static final Logger LOGGER = LoggerFactory . getLogger ( ScollectionServiceImpl . class ) ; @ Override public ActionResponseDTO < Collection > createCollection ( final Collection collection , boolean addToShelf , String resourceId , String taxonomyCode , boolean updateTaxonomyByCode , String parentId ) throws Exception { } @ Override public ActionResponseDTO < Collection > createCollection ( Collection collection , boolean addToShelf , String resourceId , String parentId , User user ) throws Exception { } protected void addCollectionTaxonomy ( Collection collection , final String taxonomyCode , boolean updateTaxonomyByCode ) { } public ActionResponseDTO < Collection > updateCollection ( final Collection newCollection , String updateCollectionId , String taxonomyCode , final String ownerUId , String creatorUId , boolean hasUnrestrictedContentAccess , String relatedContentId , boolean updateTaxonomyByCode , final User apiCallerUser ) throws Exception { } @ Override public List < ContentMetaDTO > updateContentMeta ( List < ContentMetaDTO > newDepthOfKnowledges , final String collectionId , final User apiCaller , final String type ) { } @ Override public List < ContentMetaDTO > updateContentMeta ( List < ContentMetaDTO > newDepthOfKnowledges , org . ednovo . gooru . core . api . model . Resource resource , User apiCaller , String type ) { } @ Override public void deleteCollection ( String collectionId , User user ) { final Collection collection = this . getCollectionByGooruOid ( collectionId , null ) ; rejectIfNull ( collection , GL0056 , _COLLECTION ) ; if ( this . getOperationAuthorizer ( ) . hasUnrestrictedContentAccess ( collectionId , user ) ) { try { revisionHistoryService . createVersion ( collection , SCOLLECTION_DELETE ) ; } catch ( Exception ex ) { ScollectionServiceImpl . LOGGER . error ( ( "error" + ( ex . getMessage ( ) ) ) ) ; } try { indexProcessor . index ( collection . getGooruOid ( ) , DELETE , SCOLLECTION ) ; } catch ( Exception e ) { ScollectionServiceImpl . LOGGER . error ( e . getMessage ( ) ) ; } final List < CollectionItem > collectionItems = this . getCollectionRepository ( ) . getCollectionItemByAssociation ( collectionId , null , null ) ; List < CollectionItem > parentAssociations = this . getCollectionRepository ( ) . getCollectionItemByParentId ( collectionId , null , null ) ; if ( ( parentAssociations != null ) && ( ( parentAssociations . size ( ) ) > 0 ) ) { collectionItems . addAll ( parentAssociations ) ; } try { this . getCollectionEventLog ( ) . getEventLogs ( collection . getCollectionItem ( ) , user , collection . getCollectionType ( ) ) ; } catch ( Exception e ) { ScollectionServiceImpl . LOGGER . error ( e . getMessage ( ) ) ; } for ( CollectionItem item : collectionItems ) { <START_BUG> this . deleteCollectionItem ( item . getCollectionItemId ( ) , user , true ) ; <END_BUG> if ( ( ( item . getAssociatedUser ( ) ) != null ) && ( ! ( item . getAssociatedUser ( ) . getPartyUid ( ) . equals ( user . getPartyUid ( ) ) ) ) ) { getAsyncExecutor ( ) . deleteFromCache ( ( ( ( V2_ORGANIZE_DATA ) + ( item . getAssociatedUser ( ) . getPartyUid ( ) ) ) + "*" ) ) ; } } if ( ( ( ( collection != null ) && ( ( collection . getUser ( ) ) != null ) ) && ( collection . getSharing ( ) . equalsIgnoreCase ( PUBLIC ) ) ) && ( ! ( collection . getCollectionType ( ) . equalsIgnoreCase ( PATHWAY . getType ( ) ) ) ) ) { UserSummary userSummary = this . getUserRepository ( ) . getSummaryByUid ( collection . getUser ( ) . getPartyUid ( ) ) ; if ( ( userSummary != null ) && ( ( userSummary . getCollections ( ) ) != null ) ) { userSummary . setCollections ( ( ( userSummary . getCollections ( ) ) <= 0 ? 0 : ( userSummary . getCollections ( ) ) - 1 ) ) ; this . getUserRepository ( ) . save ( userSummary ) ; } this . getUserRepository ( ) . flush ( ) ; } this . getCollectionRepository ( ) . remove ( collection ) ; for ( CollectionItem item : collectionItems ) { Collection parentCollection = item . getCollection ( ) ; if ( parentCollection . getCollectionType ( ) . equals ( FOLDER ) ) { updateFolderSharing ( parentCollection . getGooruOid ( ) ) ; } } } else { throw new org . ednovo . gooru . core . exception . UnauthorizedException ( generateErrorMessage ( "GL0010))" ) ) ; } getAsyncExecutor ( ) . deleteFromCache ( ( ( ( V2_ORGANIZE_DATA ) + ( user . getPartyUid ( ) ) ) + "*" ) ) ; getAsyncExecutor ( ) . deleteFromCache ( "v2-class-data-*" ) ; getAsyncExecutor ( ) . deleteFromCache ( ( ( "v2-collection-data-" + ( collection . getGooruOid ( ) ) ) + "*" ) ) ; } @ Override public List < Collection > getCollections ( Map < String , String > filters , User user ) { }

Fix:
this . deleteCollectionItem ( item . getCollectionItemId ( ) , user , false ) ;