Buggy code:
@ Service ( "userRegistrationService" ) public class UserRegistrationService { private static final Logger LOGGER = LoggerFactory . getLogger ( UserRegistrationService . class ) ; private static final Set < String > DEFAULT_USER_ROLES = Sets . newHashSet ( "user" ) ; private static final List < String > DEFAULT_ACCOUNT_ROLES = Lists . newArrayList ( "account//owner" ) ; private static final List < String > DEFAULT_WORKSPACE_ROLES = Lists . newArrayList ( "workspace//admin" , "workspace//developer" ) ; private static final String FORGOT_PASSWORD_SALT_KEY = "forgot_password_token_salt" ; @ Autowired UserEntityService userEntityService ; @ Autowired AccountEntityService accountEntityService ; @ Autowired AccountMemberEntityService accountMemberEntityService ; @ Autowired WorkspaceEntityService workspaceEntityService ; @ Autowired WorkspaceMemberService workspaceMemberService ; @ Autowired ProfileEntityService profileEntityService ; @ Autowired NotificationRepository notificationRepository ; @ Autowired UserTokenEntityService userTokenEntityService ; @ Autowired NotificationSender notificationSender ; public boolean validateEmail ( String email ) { } public boolean validateUsername ( String username ) { } private boolean isValidUsername ( String username ) { } private boolean isValidEmail ( String email ) { } public boolean validatePassword ( String password ) { } @ Transactional public User register ( String email , String username , String password ) throws ConflictException { try { UserEntity userEntity = new UserEntity ( ) ; userEntity . getAliases ( ) . add ( email ) ; userEntity . getAliases ( ) . add ( username ) ; userEntity . setPasswordHash ( userEntityService . generatePasswordHash ( password ) ) ; userEntity . getRoles ( ) . addAll ( UserRegistrationService . DEFAULT_USER_ROLES ) ; userEntity . setUserId ( NameGenerator . generate ( "user-" , ID_LENGTH ) ) ; userEntity . getPreferences ( ) . put ( EMAIL , email ) ; userEntity = userEntityService . save ( userEntity ) ; profileEntityService . save ( profileEntityService . toProfileEntity ( new Profile ( ) . withId ( userEntity . getUserId ( ) ) . withUserId ( userEntity . getUserId ( ) ) , Optional . empty ( ) ) ) ; AccountEntity account = new AccountEntity ( ) ; account . setAccountId ( NameGenerator . generate ( "acc-" , org . eclipse . che . api . account . server . Constants . ID_LENGTH ) ) ; account . setName ( ( username + "-account" ) ) ; account = accountEntityService . save ( account ) ; accountMemberEntityService . create ( new Member ( ) . withAccountId ( account . getAccountId ( ) ) . withUserId ( userEntity . getUserId ( ) ) . withRoles ( UserRegistrationService . DEFAULT_ACCOUNT_ROLES ) ) ; WorkspaceEntity workspaceEntity = new WorkspaceEntity ( ) ; workspaceEntity . setAccount ( account ) ; workspaceEntity . setWorkspaceId ( NameGenerator . generate ( Workspace . class . getSimpleName ( ) . toLowerCase ( ) , org . eclipse . che . api . workspace . server . Constants . ID_LENGTH ) ) ; workspaceEntity . setName ( ( username + "-ws" ) ) ; workspaceEntity . setTemporary ( false ) ; workspaceEntity = workspaceEntityService . create ( workspaceEntity ) ; workspaceMemberService . create ( new org . eclipse . che . api . workspace . server . dao . Member ( ) . withUserId ( userEntity . getUserId ( ) ) . withWorkspaceId ( workspaceEntity . getWorkspaceId ( ) ) . withRoles ( UserRegistrationService . DEFAULT_WORKSPACE_ROLES ) ) ; NotificationEntity notificationEntity = new NotificationEntity ( ) ; notificationEntity . setStatus ( CREATED ) ; notificationEntity . setUserNotified ( userEntity ) ; notificationEntity . setEvent ( USER_REGISTERED ) ; notificationEntity . setChannel ( NotificationChannel . EMAIL ) ; notificationEntity . setDestination ( email ) ; <START_BUG> notificationEntity = notificationRepository . saveAndFlush ( notificationEntity ) ; <END_BUG> notificationSender . releaseNotification ( notificationEntity ) ; return userEntityService . toUser ( userEntity ) ; } catch ( Exception e ) { UserRegistrationService . LOGGER . warn ( "Error<seq2seq4repair_space>registering<seq2seq4repair_space>user" , e ) ; throw new ConflictException ( "Error<seq2seq4repair_space>creating<seq2seq4repair_space>user" ) ; } } public void forgotPassword ( String email ) throws NotFoundException { } String generateTemporaryValidationToken ( UserEntity user ) { } public UserTokenEntity validateToken ( String tokenOrigin ) throws ConflictException , NotFoundException { } protected String getValidationHash ( UserEntity user ) { } }

Fix:
notificationEntity = notificationRepository . save ( notificationEntity ) ;