rethianita / spring-book

Overly generic exceptions should not be thrown JAVA-W1042
Anti-pattern
Major
2 years ago2 years old
authenticationManager should throw an exception more specific than Exception
 58
 59  @Bean
 60  public AuthenticationManager authenticationManager(
 61      HttpSecurity http, BCryptPasswordEncoder bCryptPasswordEncoder) throws Exception { 62    return http.getSharedObject(AuthenticationManagerBuilder.class)
 63        .userDetailsService(
 64            username ->
securityFilterChain should throw an exception more specific than Exception
 73  }
 74
 75  @Bean
 76  public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { 77    // Enable CORS and disable CSRF
 78    http.cors().and().csrf().disable();
 79
authenticationManager should throw an exception more specific than Exception
166  // Expose authentication manager bean
167  @Bean
168  public AuthenticationManager authenticationManager(
169      AuthenticationConfiguration authenticationConfiguration) throws Exception {170    return authenticationConfiguration.getAuthenticationManager();
171  }
172}
downloadFileFromURL should throw an exception more specific than Exception
 95        }
 96    }
 97
 98    private static void downloadFileFromURL(String urlString, File destination) throws Exception { 99        if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
100            String username = System.getenv("MVNW_USERNAME");
101            char[] password = System.getenv("MVNW_PASSWORD").toCharArray();