Buggy code:
@ 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 ) { } @ Override public List < Collection > getCollections ( Map < String , String > filters , User user ) { } @ Override public ActionResponseDTO < CollectionItem > createCollectionItem ( String resourceGooruOid , String collectionGooruOid , CollectionItem collectionItem , User user , String type , boolean isCreateQuestion ) throws Exception { final Collection collection = this . createMyShelfCollection ( collectionGooruOid , user , type , collectionItem ) ; collectionItem . setAssociatedUser ( user ) ; collectionItem . setAssociationDate ( new Date ( System . currentTimeMillis ( ) ) ) ; org . ednovo . gooru . core . api . model . Resource resource = this . getResourceRepository ( ) . findResourceByContentGooruId ( resourceGooruOid ) ; final Errors errors = validateCollectionItem ( collection , resource , collectionItem ) ; if ( ! ( errors . hasErrors ( ) ) ) { collectionItem . setCollection ( collection ) ; if ( ( collectionItem . getCollection ( ) ) != null ) { collectionItem . getCollection ( ) . setLastUpdatedUserUid ( user . getPartyUid ( ) ) ; } if ( ( ( ! isCreateQuestion ) && ( resource != null ) ) && ( resource . getResourceType ( ) . getName ( ) . equalsIgnoreCase ( ASSESSMENT_QUESTION . getType ( ) ) ) ) { AssessmentQuestion assessmentQuestion = assessmentService . copyAssessmentQuestion ( user , resource . getGooruOid ( ) ) ; collectionItem . setResource ( assessmentQuestion ) ; } else { collectionItem . setResource ( resource ) ; } int sequence = ( ( collectionItem . getCollection ( ) . getCollectionItems ( ) ) != null ) ? ( collectionItem . getCollection ( ) . getCollectionItems ( ) . size ( ) ) + 1 : 1 ; collectionItem . setItemSequence ( sequence ) ; collectionItem . getCollection ( ) . setItemCount ( sequence ) ; this . getCollectionRepository ( ) . save ( collectionItem ) ; try { <START_BUG> this . getCollectionEventLog ( ) . getEventLogs ( collectionItem , true , false , user , false ) ; <END_BUG> } catch ( Exception e ) { ScollectionServiceImpl . LOGGER . error ( e . getMessage ( ) ) ; } try { if ( ! ( collectionItem . getCollection ( ) . getResourceType ( ) . getName ( ) . equalsIgnoreCase ( SHELF ) ) ) { indexProcessor . index ( collectionItem . getCollection ( ) . getGooruOid ( ) , INDEX , SCOLLECTION ) ; } if ( ( ( ( ( collectionItem . getResource ( ) . getResourceType ( ) ) != null ) && ( ! ( collectionItem . getResource ( ) . getResourceType ( ) . getName ( ) . equalsIgnoreCase ( SCOLLECTION ) ) ) ) && ( ! ( collectionItem . getResource ( ) . getResourceType ( ) . getName ( ) . equalsIgnoreCase ( FOLDER ) ) ) ) && ( ! ( collectionItem . getResource ( ) . getResourceType ( ) . getName ( ) . equalsIgnoreCase ( CLASSPAGE ) ) ) ) { indexProcessor . index ( collectionItem . getResource ( ) . getGooruOid ( ) , INDEX , RESOURCE ) ; } } catch ( Exception e ) { ScollectionServiceImpl . LOGGER . error ( e . getMessage ( ) ) ; } final List < String > parenFolders = this . getParentCollection ( resource . getGooruOid ( ) , collection . getUser ( ) . getPartyUid ( ) , false ) ; for ( String parentFolder : parenFolders ) { updateFolderSharing ( parentFolder ) ; } if ( ( ( collectionItem . getCollection ( ) . getResourceType ( ) . getName ( ) . equalsIgnoreCase ( SCOLLECTION ) ) && ( ( collectionItem . getCollection ( ) . getClusterUid ( ) ) != null ) ) && ( ! ( collectionItem . getCollection ( ) . getClusterUid ( ) . equalsIgnoreCase ( collectionItem . getCollection ( ) . getGooruOid ( ) ) ) ) ) { collectionItem . getCollection ( ) . setClusterUid ( collectionItem . getCollection ( ) . getGooruOid ( ) ) ; this . getCollectionRepository ( ) . save ( collectionItem . getCollection ( ) ) ; } try { this . getCollectionRepository ( ) . flush ( ) ; }

Fix:
this . getCollectionEventLog ( ) . getEventLogs ( collectionItem , true , true , user , false ) ;