Buggy code:
public class UserService { public static void createDefaultUsers ( ) { } public static List < ODocument > getUsers ( QueryParams criteria , boolean excludeInternal ) throws SqlInjectionException { } public static List < ODocument > getUsers ( QueryParams criteria ) throws SqlInjectionException { } public static ODocument getCurrentUser ( ) throws SqlInjectionException { } public static OUser getOUserByUsername ( String username ) { } public static ODocument getUserProfilebyUsername ( String username ) throws SqlInjectionException { } public static String getUsernameByProfile ( ODocument profile ) throws InvalidModelException { } public static ODocument signUp ( String username , String password , Date signupDate , JsonNode nonAppUserAttributes , JsonNode privateAttributes , JsonNode friendsAttributes , JsonNode appUsersAttributes , boolean generated ) throws EmailAlreadyUsedException , UserAlreadyExistsException , InvalidJsonException { } public static void registerDevice ( Map < String , Object > data ) throws SqlInjectionException { } public static void unregisterDevice ( String pushToken ) throws SqlInjectionException { } public static void logout ( String pushToken ) throws SqlInjectionException { } public static ODocument signUp ( String username , String password , Date signupDate , String role , JsonNode nonAppUserAttributes , JsonNode privateAttributes , JsonNode friendsAttributes , JsonNode appUsersAttributes , boolean generated , String id ) throws EmailAlreadyUsedException , UserAlreadyExistsException , InvalidJsonException { } public static ODocument signUp ( String username , String password , Date signupDate , String role , JsonNode nonAppUserAttributes , JsonNode privateAttributes , JsonNode friendsAttributes , JsonNode appUsersAttributes , boolean generated ) throws EmailAlreadyUsedException , UserAlreadyExistsException , InvalidJsonException { } public static ODocument updateProfile ( ODocument profile , JsonNode nonAppUserAttributes , JsonNode privateAttributes , JsonNode friendsAttributes , JsonNode appUsersAttributes ) throws Exception { } public static ODocument updateCurrentProfile ( JsonNode nonAppUserAttributes , JsonNode privateAttributes , JsonNode friendsAttributes , JsonNode appUsersAttributes ) throws Exception { } public static ODocument updateProfile ( String username , String role , JsonNode nonAppUserAttributes , JsonNode privateAttributes , JsonNode friendsAttributes , JsonNode appUsersAttributes ) throws AdminCannotChangeRoleException , InvalidJsonException , Exception { } public static ODocument updateProfile ( String username , String role , JsonNode nonAppUserAttributes , JsonNode privateAttributes , JsonNode friendsAttributes , JsonNode appUsersAttributes , String id ) throws AdminCannotChangeRoleException , InvalidJsonException , Exception { } public static void changePasswordCurrentUser ( String newPassword ) throws OpenTransactionException { } public static void changePassword ( String username , String newPassword ) throws SqlInjectionException , OpenTransactionException , UserNotFoundException { } public static boolean exists ( String username ) { } public static void sendResetPwdMail ( String appCode , ODocument user ) throws Exception { } public static void resetUserPasswordFinalStep ( String username , String newPassword ) throws ResetPasswordException , SqlInjectionException { } public static void removeSocialLoginTokens ( ODocument user , String socialNetwork ) throws ODatabaseException { } public static void addSocialLoginTokens ( ODocument user , UserInfo userInfo ) throws ODatabaseException { } public static void moveUsersToRole ( String from , String to ) { } public static void addUserToRole ( String username , String role ) throws OpenTransactionException { } public static void removeUserFromRole ( String username , String role ) throws OpenTransactionException { boolean admin = false ; <START_BUG> if ( ! ( DbHelper . currentUsername ( ) . equals ( BBConfiguration . getInstance ( ) . getBaasBoxAdminUsername ( ) ) ) ) { <END_BUG> DbHelper . reconnectAsAdmin ( ) ; admin = true ; } String sqlRemove = "update<seq2seq4repair_space>ouser<seq2seq4repair_space>remove<seq2seq4repair_space>roles<seq2seq4repair_space>=<seq2seq4repair_space>{FROM_ROLE}<seq2seq4repair_space>where<seq2seq4repair_space>roles<seq2seq4repair_space>contains<seq2seq4repair_space>{FROM_ROLE}<seq2seq4repair_space>and<seq2seq4repair_space>name<seq2seq4repair_space>=<seq2seq4repair_space>?" ; ORole fromRole = RoleDao . getRole ( role ) ; ORID fromRID = fromRole . getDocument ( ) . getRecord ( ) . getIdentity ( ) ; sqlRemove = sqlRemove . replace ( "{FROM_ROLE}" , fromRID . toString ( ) ) ; GenericDao . getInstance ( ) . executeCommand ( sqlRemove , new String [ ] { username } ) ; if ( admin ) { DbHelper . reconnectAsAuthenticatedUser ( ) ; } } public static void moveUserToRole ( String username , String from , String to ) { } public static void disableUser ( String username ) throws OpenTransactionException , UserNotFoundException { } public static void disableCurrentUser ( ) throws OpenTransactionException , UserNotFoundException { } public static void enableUser ( String username ) throws OpenTransactionException , UserNotFoundException { } public static List < ODocument > getUserProfileByUsernames ( List < String > usernames , QueryParams criteria ) throws SqlInjectionException { } public static List < ODocument > getUserProfilebyUsernames ( List < String > usernames ) throws SqlInjectionException { } public static boolean userCanByPassRestrictedAccess ( String userName ) { } public static ORole getUserRole ( String username ) { } public static boolean isInternalUsername ( String username ) { } public static boolean isSocialAccount ( String username ) throws SqlInjectionException { } public static String generateFakeUserPassword ( String username , Date signupDate ) { } public static void changeUsername ( String currentUsername , String newUsername ) throws SqlInjectionException , OpenTransactionException , UserNotFoundException { } public static void dropUser ( OUser user ) throws Throwable { } public static boolean isAnAdmin ( String username ) { } }

Fix:
if ( ! ( UserService . isAnAdmin ( DbHelper . getCurrentUserNameFromConnection ( ) ) ) ) {