java – Spring Boot API – Avoiding Concurrency issues

I’m still in the process of learning Java / spring and I think I’m getting better. Now at this point I’m able to build a rest api BUT I’m at a lost at how to ensure I’ve no concurrency issues . I’ve read quite a bit of documentation on having my classes stateless and I “think” I’ve achieved that.

Could I get a code review please to see if anything here would be an issue should there be say xxx concurrent requests to the controller below.

Below i have a POJO called User:

@Getter
@Setter
@Document(collection = "UserProfiles")
public class User {
    @Id
    @JsonIgnore
    private String _id;

    @JsonView({ProfileViews.Intro.class, ProfileViews.Full.class})
    private String userId;

    @JsonView({ProfileViews.Intro.class, ProfileViews.Full.class})
    private String name;

    @JsonView({ProfileViews.Intro.class, ProfileViews.Full.class})
    private String displayName;

    @DBRef
    @JsonView({ProfileViews.Full.class})
    private UserInterests personalInterests;

    @DBRef
    @JsonIgnore
    private ProfileFollows profileFollowDetails;

}

@Getter
@Setter
@Document(collection = "ProfileFollows")
public class ProfileFollows {
    @Id
    //Id of The Mongo Document
    private String id;

    //The Id of the User Profile who owns the document
    private String userId;

    //A list containing the Ids of the Users who have followed the Profile belonging to userId
    private List<String> profileFollowedByUserIds;

    //A list containing the Ids of the Profiles the current user has followed
    private List<String> profileFollowingByUserList;
}

And here is my Service layer where I create and update the user

@Service
public class UserService {

    @Autowired
    UserDal userDal;

    public User createNewUserAccount(String userId, String userName) {
        //check If userId already in DB

        if (checkIfUserIdExits(userId)) {
            throw new UserAlreadyExistsException("Cannot create User with Id { " + userId + " }, a user with this Id already " +
                    "exists");
        }

        //Create a Empty / Base New User Object
        User newUser = new User();
    
        UserInterests userInterests = new UserInterests();
        userInterests.setUserId(userId);
        userInterests.setPersonalInterestsExtras(null);
        userInterests.setCreatedDate(Instant.now());
        userInterests.setLastUpdatedAt(Instant.now());
        userInterestsDAL.save(userInterests);

        newUser.setPersonalInterests(userInterests);

        ProfileFollows userProfileFollows = new ProfileFollows();
        userProfileFollows.setUserId(userId);
        userProfileFollows.setProfileFollowedByUserIds(new ArrayList<>());
        userProfileFollows.setProfileFollowingByUserList(new ArrayList<>());
        newUser.setProfileFollowDetails(profileFollowsDAL.save(userProfileFollows));


        newUser.setUserId(userId);
        newUser.setDisplayName(generateUserDisplayName(userName));
        newUser.setCreatedDate(Instant.now());
        newUser.setLastUpdatedAt(Instant.now());

        //save the new User Profile to the DB
        return userDal.save(newUser);
    }

Here is my UserDAL:

public interface UserDal {
    /**
     * Method to check if a user exists with a given user Id
     * @param Id -- Id of user to look up where id is a string
     * @return
     */
    Boolean existsById(String Id);

    /**
     * Method to save a user to the DB
     * @param user -- User object to save to the DB
     * @return
     */
    User save(User user);
}

My User Repository / DALImpl:

@Repository
public class UserDALImpl implements UserDal {

    private final MongoTemplate mongoTemplate;

    @Autowired
    public UserDALImpl(MongoTemplate mongoTemplate) {
        this.mongoTemplate = mongoTemplate;
    }

  @Override
    public User save(User user) {
        return mongoTemplate.save(user);
    }

And lastly my controller:

@RestController
@RequestMapping("/profile")
public class CreateProfileController {

    @Autowired
    public CreateProfileController() {
    }

    @Autowired
    UserService userService;

    @ApiOperation(value = "Allows for the creation of a user Profile")
    @PostMapping("/create")
    public User createUserProfile(@RequestParam(name = "userId") String userId,
                                  @RequestParam(name = "displayName", required = true, defaultValue = "AnonymousDev") String displayName) {

        if (userId.equals("")) throw new BadRequestException("UserId cannot be blank");

        if (userService.checkIfUserIdExits(userId)) {
            throw new UserAlreadyExistsException("Unable to create user with Id { " + userId + " }, the " +
                    "userId already exists");
        }
        return userService.createNewUserAccount(userId, displayName);
    }
}

Thank you for your time