I have a requirement where in program execution flow should continue even after throwing an exception.
for(DataSource source : dataSources) {
try {
/
If you are not breaking the loop somehow inside the catch block, then the other iterations will just continue, regardless of whether an exception was thrown in a previous iteration.
Try this simple example and see what happens:
List list = new ArrayList();
list.add("1");
list.add("2");
list.add("3");
for(String str: list) {
try {
System.out.println(str);
throw new Exception("Exception for string " + str);
} catch(Exception ex) {
System.out.println("Caught exception");
}
}
You will see that all iteration execute, even though each one throws an exception.