Buggy code:
@ Transactional @ Authenticated ( { LoggedIn . class , HasRole . class } ) public final class TrainingProblemController extends BaseController { private static final long PAGE_SIZE = 20 ; private final Sandalphon sandalphon ; private final CurriculumService curriculumService ; private final CurriculumCourseService curriculumCourseService ; private final CourseService courseService ; private final CourseSessionService courseSessionService ; private final SessionService sessionService ; private final SessionDependencyService sessionDependencyService ; private final SessionProblemService sessionProblemService ; private final UserItemService userItemService ; public TrainingProblemController ( Sandalphon sandalphon , CurriculumService curriculumService , CurriculumCourseService curriculumCourseService , CourseService courseService , CourseSessionService courseSessionService , SessionService sessionService , SessionDependencyService sessionDependencyService , SessionProblemService sessionProblemService , UserItemService userItemService ) { } public Result viewProblems ( long curriculumId , long curriculumCourseId , long courseSessionId ) throws CourseNotFoundException , CourseSessionNotFoundException , CurriculumCourseNotFoundException , CurriculumNotFoundException , SessionNotFoundException { } public Result listProblems ( long curriculumId , long curriculumCourseId , long courseSessionId , long page , String orderBy , String orderDir , String filterString ) throws CourseNotFoundException , CourseSessionNotFoundException , CurriculumCourseNotFoundException , CurriculumNotFoundException , SessionNotFoundException { } public Result viewProblem ( long curriculumId , long curriculumCourseId , long courseSessionId , long sessionProblemId ) throws CourseNotFoundException , CourseSessionNotFoundException , CurriculumCourseNotFoundException , CurriculumNotFoundException , SessionNotFoundException , SessionProblemNotFoundException { Curriculum curriculum = curriculumService . findCurriculumByCurriculumId ( curriculumId ) ; CurriculumCourse curriculumCourse = curriculumCourseService . findCurriculumCourseByCurriculumCourseId ( curriculumCourseId ) ; CourseSession courseSession = courseSessionService . findByCourseSessionId ( courseSessionId ) ; SessionProblem sessionProblem = sessionProblemService . findSessionProblemBySessionProblemId ( sessionProblemId ) ; if ( ( ( curriculum . getJid ( ) . equals ( curriculumCourse . getCurriculumJid ( ) ) ) && ( curriculumCourse . getCourseJid ( ) . equals ( courseSession . getCourseJid ( ) ) ) ) && ( sessionProblem . getSessionJid ( ) . equals ( courseSession . getSessionJid ( ) ) ) ) { Course course = courseService . findCourseByCourseJid ( curriculumCourse . getCourseJid ( ) ) ; Session session = sessionService . findSessionBySessionJid ( courseSession . getSessionJid ( ) ) ; String reasonNotAllowedToSubmit = null ; if ( ! ( sessionDependencyService . isDependenciesFulfilled ( IdentityUtils . getUserJid ( ) , session . getJid ( ) ) ) ) { reasonNotAllowedToSubmit = Messages . get ( "training.session.isLocked" ) ; } String postSubmitUri = null ; if ( BUNDLE . equals ( sessionProblem . getType ( ) ) ) { postSubmitUri = TrainingBundleSubmissionController . postSubmitProblem ( curriculum . getId ( ) , curriculumCourse . getId ( ) , courseSession . getId ( ) , sessionProblem . getProblemJid ( ) ) . absoluteURL ( request ( ) , request ( ) . secure ( ) ) ; } else if ( PROGRAMMING . equals ( sessionProblem . getType ( ) ) ) { postSubmitUri = TrainingProgrammingSubmissionController . postSubmitProblem ( curriculum . getId ( ) , curriculumCourse . getId ( ) , courseSession . getId ( ) , sessionProblem . getProblemJid ( ) ) . absoluteURL ( request ( ) , request ( ) . secure ( ) ) ; } String requestUrl = sandalphon . getProblemStatementRenderUri ( ) . toString ( ) ; String requestBody = sandalphon . getProblemStatementRenderRequestBody ( sessionProblem . getProblemJid ( ) , sessionProblem . getProblemSecret ( ) , System . currentTimeMillis ( ) , SessionControllerUtils . getCurrentStatementLanguage ( ) , postSubmitUri , routes . TrainingProblemController . switchLanguage ( ) . absoluteURL ( request ( ) , request ( ) . secure ( ) ) , reasonNotAllowedToSubmit , LanguageRestriction . defaultRestriction ( ) ) ; LazyHtml content = new LazyHtml ( viewProblemView . render ( requestUrl , requestBody ) ) ; SessionControllerUtils . appendViewLayout ( content , curriculum , curriculumCourse , courseSession , session ) ; ControllerUtils . getInstance ( ) . appendSidebarLayout ( content ) ; ControllerUtils . getInstance ( ) . appendBreadcrumbsLayout ( content , ImmutableList . of ( new org . iatoki . judgels . commons . InternalLink ( Messages . get ( "training.curriculums" ) , TrainingController . jumpToCurriculums ( ) ) , new org . iatoki . judgels . commons . InternalLink ( curriculum . getName ( ) , TrainingController . jumpToCourses ( curriculum . getId ( ) ) ) , new org . iatoki . judgels . commons . InternalLink ( course . getName ( ) , TrainingController . jumpToSessions ( curriculum . getId ( ) , curriculumCourse . getId ( ) ) ) , new org . iatoki . judgels . commons . InternalLink ( session . getName ( ) , TrainingController . jumpToProblems ( curriculum . getId ( ) , curriculumCourse . getId ( ) , courseSession . getId ( ) ) ) , new org . iatoki . judgels . commons . InternalLink ( sessionProblem . getAlias ( ) , routes . TrainingProblemController . viewProblem ( curriculum . getId ( ) , curriculumCourse . getId ( ) , courseSession . getId ( ) , sessionProblem . getId ( ) ) ) ) ) ; <START_BUG> if ( ! ( userItemService . isUserItemExist ( IdentityUtils . getUserJid ( ) , sessionProblem . getProblemJid ( ) , VIEWED ) ) ) { <END_BUG> userItemService . upsertUserItem ( IdentityUtils . getUserJid ( ) , sessionProblem . getProblemJid ( ) , VIEWED ) ; } ControllerUtils . getInstance ( ) . appendTemplateLayout ( content , "Training" ) ; return ControllerUtils . getInstance ( ) . lazyOk ( content ) ; } else { return notFound ( ) ; } } public Result switchLanguage ( ) { } public Result renderProblemMedia ( long curriculumId , long curriculumCourseId , long courseSessionId , long sessionProblemId , String filename ) throws CourseNotFoundException , CourseSessionNotFoundException , CurriculumCourseNotFoundException , CurriculumNotFoundException , SessionNotFoundException , SessionProblemNotFoundException { } private Result showListProblems ( Curriculum curriculum , CurriculumCourse curriculumCourse , Course course , CourseSession courseSession , Session session , Page < SessionProblemProgress > currentPage , String orderBy , String orderDir , String filterString ) { } }

Fix:
if ( ! ( userItemService . isUserItemExist ( IdentityUtils . getUserJid ( ) , sessionProblem . getProblemJid ( ) ) ) ) {