Buggy code:
if ( ( insert . getTimestamp ( ) ) > ( maxLog ) ) { maxLog = insert . getTimestamp ( ) ; } if ( ( ( ( insert . getCourse ( ) ) != null ) && ( ( insert . getForum ( ) ) != null ) ) && ( ( insert . getUser ( ) ) != null ) ) { forumLogMining . put ( insert . getId ( ) , insert ) ; } } if ( ( ( loadedItem . getObjecttable ( ) ) != null ) && ( loadedItem . getObjecttable ( ) . equals ( "forum_discussions" ) ) ) { final ForumLogMining insert = new ForumLogMining ( ) ; insert . setId ( ( ( ( forumLogMining . size ( ) ) + 1 ) + ( this . forumLogMax ) ) ) ; insert . setPlatform ( this . connector . getPlatformId ( ) ) ; insert . setAction ( ( ( loadedItem . getAction ( ) ) + "<seq2seq4repair_space>discussion" ) ) ; insert . setTimestamp ( loadedItem . getTimecreated ( ) ) ; insert . setCourse ( Long . valueOf ( ( ( ( this . connector . getPrefix ( ) ) + "" ) + ( loadedItem . getCourse ( ) ) ) ) , this . courseMining , this . oldCourseMining ) ; insert . setUser ( Long . valueOf ( ( ( ( this . connector . getPrefix ( ) ) + "" ) + ( loadedItem . getUser ( ) ) ) ) , this . userMining , this . oldUserMining ) ; if ( discussions . containsKey ( loadedItem . getObjectid ( ) ) ) { Long f = discussions . get ( loadedItem . getObjectid ( ) ) . getForum ( ) ; insert . setForum ( Long . valueOf ( ( ( ( this . connector . getPrefix ( ) ) + "" ) + f ) ) , this . forumMining , this . oldForumMining ) ; insert . setSubject ( discussions . get ( loadedItem . getObjectid ( ) ) . getName ( ) ) ; } if ( ( insert . getTimestamp ( ) ) > ( maxLog ) ) { maxLog = insert . getTimestamp ( ) ; } if ( ( ( ( insert . getCourse ( ) ) != null ) && ( ( insert . getForum ( ) ) != null ) ) && ( ( insert . getUser ( ) ) != null ) ) { forumLogMining . put ( insert . getId ( ) , insert ) ; } } if ( ( ( ( loadedItem . getObjecttable ( ) ) != null ) && ( loadedItem . getObjecttable ( ) . equals ( "forum_posts" ) ) ) && ( loadedItem . getTarget ( ) . equals ( "post" ) ) ) { final ForumLogMining insert = new ForumLogMining ( ) ; insert . setId ( ( ( ( forumLogMining . size ( ) ) + 1 ) + ( this . forumLogMax ) ) ) ; insert . setPlatform ( this . connector . getPlatformId ( ) ) ; insert . setAction ( ( ( loadedItem . getAction ( ) ) + "<seq2seq4repair_space>post" ) ) ; insert . setTimestamp ( loadedItem . getTimecreated ( ) ) ; insert . setCourse ( Long . valueOf ( ( ( ( this . connector . getPrefix ( ) ) + "" ) + ( loadedItem . getCourse ( ) ) ) ) , this . courseMining , this . oldCourseMining ) ; insert . setUser ( Long . valueOf ( ( ( ( this . connector . getPrefix ( ) ) + "" ) + ( loadedItem . getUser ( ) ) ) ) , this . userMining , this . oldUserMining ) ; ForumPostsLMS p = posts . get ( loadedItem . getObjectid ( ) ) ; <START_BUG> if ( discussions . containsKey ( p . getDiscussion ( ) ) ) { <END_BUG> insert . setForum ( Long . valueOf ( ( ( ( this . connector . getPrefix ( ) ) + "" ) + ( discussions . get ( p . getDiscussion ( ) ) . getForum ( ) ) ) ) , this . forumMining , this . oldForumMining ) ; insert . setSubject ( p . getSubject ( ) ) ; insert . setMessage ( TextHelper . replaceString ( p . getMessage ( ) ) ) ; } if ( ( insert . getTimestamp ( ) ) > ( maxLog ) ) { maxLog = insert . getTimestamp ( ) ; } if ( ( ( ( insert . getCourse ( ) ) != null ) && ( ( insert . getForum ( ) ) != null ) ) && ( ( insert . getUser ( ) ) != null ) ) { forumLogMining . put ( insert . getId ( ) , insert ) ; } } } for ( final ForumLogMining r : forumLogMining . values ( ) ) { if ( ( r . getUser ( ) ) != null ) { long duration = - 1 ; final ArrayList < Long > times = users . get ( r . getUser ( ) . getId ( ) ) ; final int pos = times . indexOf ( r . getTimestamp ( ) ) ; if ( ( pos > ( - 1 ) ) && ( pos < ( ( times . size ( ) ) - 1 ) ) ) { if ( ( times . get ( ( pos + 1 ) ) ) != 0 ) { duration = ( times . get ( ( pos + 1 ) ) ) - ( times . get ( pos ) ) ; }

Fix:
if ( ( p != null ) && ( discussions . containsKey ( p . getDiscussion ( ) ) ) ) {