View Javadoc
1   /*
2   FallThrough
3   checkLastCaseGroup = (default)false
4   reliefPattern = (default)falls?[ -]?thr(u|ough)
5   
6   
7   */
8   
9   package com.puppycrawl.tools.checkstyle.checks.coding.fallthrough;
10  
11  import java.io.IOException;
12  
13  public class InputFallThroughTryCatchInSwitch {
14      public int foo(int x) {
15          switch (x) {
16              case 1:
17                  try {
18                      // Some code
19                      throw new IOException("Exception occurred.");
20                  } catch (IOException e) {
21                      // Some code
22                      if (e.getMessage().contains("Exception")) {
23                          break;
24                      } else {
25                          return 0;
26                      }
27                  } catch (Exception e) {
28                      // Some code
29                      for (int i = 0; i < 3; i++) {
30                          if (i == 1) {
31                              break;
32                          }
33                      }
34                  } finally {
35                      // Some code
36                  }
37              default: // violation 'Fall\ through from previous branch of the switch statement.'
38                  // Some code
39          }
40  
41          return 0;
42      }
43  }