| 1 | package edu.ucsb.cs156.frontiers.startup; | |
| 2 | ||
| 3 | import lombok.extern.slf4j.Slf4j; | |
| 4 | ||
| 5 | import java.util.ArrayList; | |
| 6 | import java.util.List; | |
| 7 | ||
| 8 | import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | import org.springframework.beans.factory.annotation.Value; | |
| 10 | import org.springframework.stereotype.Component; | |
| 11 | import edu.ucsb.cs156.frontiers.entities.Admin; | |
| 12 | import edu.ucsb.cs156.frontiers.repositories.AdminRepository; | |
| 13 | ||
| 14 | import edu.ucsb.cs156.frontiers.services.jobs.JobContextConsumer; | |
| 15 | ||
| 16 | /** This class contains a `run` method that is called once at application startup time. */ | |
| 17 | @Slf4j | |
| 18 | @Component | |
| 19 | public class FrontiersStartup { | |
| 20 | ||
| 21 | @Value("#{'${app.admin.emails}'.split(',')}") | |
| 22 | List<String> adminEmails; | |
| 23 | @Autowired AdminRepository adminRepository; | |
| 24 | ||
| 25 | /** | |
| 26 | * Called once at application startup time . Put code here if you want it to run once each time | |
| 27 | * the Spring Boot application starts up in all environments. | |
| 28 | */ | |
| 29 | public void alwaysRunOnStartup() { | |
| 30 | log.info("alwaysRunOnStartup called"); | |
| 31 | try { | |
| 32 |
1
1. alwaysRunOnStartup : removed call to java/util/List::forEach → KILLED |
adminEmails.forEach( |
| 33 | (email) -> { | |
| 34 | Admin admin = new Admin(email); | |
| 35 | adminRepository.save(admin); | |
| 36 | } | |
| 37 | ); | |
| 38 | } catch (Exception e) { | |
| 39 | log.error("Error in loading all ADMIN_EMAILS:", e); | |
| 40 | } | |
| 41 | } | |
| 42 | } | |
Mutations | ||
| 32 |
1.1 |