TSK-987: Fix Spotbugs - exception is caught when exception is not thrown
This commit is contained in:
parent
3e9ea4d1d9
commit
2f7d0d359b
|
@ -12,6 +12,7 @@ import java.sql.Connection;
|
|||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import javax.sql.DataSource;
|
||||
import org.apache.ibatis.jdbc.RuntimeSqlException;
|
||||
import org.apache.ibatis.jdbc.ScriptRunner;
|
||||
import org.apache.ibatis.jdbc.SqlRunner;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -93,7 +94,7 @@ public class DbSchemaCreator {
|
|||
return true;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (RuntimeSqlException | SQLException e) {
|
||||
LOGGER.error(
|
||||
"Schema version not valid. The VERSION property in table TASKANA_SCHEMA_VERSION "
|
||||
+ "has not the expected value {}",
|
||||
|
@ -139,7 +140,7 @@ public class DbSchemaCreator {
|
|||
BufferedReader reader =
|
||||
new BufferedReader(new InputStreamReader(resourceAsStream, StandardCharsets.UTF_8));
|
||||
runner.runScript(getSqlSchemaNameParsed(reader));
|
||||
} catch (Exception e) {
|
||||
} catch (RuntimeSqlException | SQLException e) {
|
||||
LOGGER.debug("Schema does not exist.");
|
||||
if (!errorWriter.toString().trim().isEmpty()) {
|
||||
LOGGER.debug(errorWriter.toString());
|
||||
|
|
|
@ -2,6 +2,7 @@ package pro.taskana.security;
|
|||
|
||||
import static pro.taskana.configuration.TaskanaEngineConfiguration.shouldUseLowerCaseForAccessIds;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.AccessController;
|
||||
import java.security.Principal;
|
||||
|
@ -109,7 +110,11 @@ public final class CurrentUserContext {
|
|||
return userIdUsed;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (RuntimeException
|
||||
| ClassNotFoundException
|
||||
| IllegalAccessException
|
||||
| InvocationTargetException
|
||||
| NoSuchMethodException e) {
|
||||
LOGGER.warn("Could not get user from WSSubject. Going ahead unauthorized.");
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -98,7 +98,7 @@ public class SampleDataGenerator {
|
|||
String query = "SELECT 1 FROM " + tableSafe + " LIMIT 1;";
|
||||
runner.run(query);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
} catch (RuntimeSqlException | SQLException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,9 @@ import org.springframework.stereotype.Component;
|
|||
import pro.taskana.Task;
|
||||
import pro.taskana.TaskService;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.SystemException;
|
||||
import pro.taskana.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.impl.TaskImpl;
|
||||
import pro.taskana.rest.TaskController;
|
||||
|
||||
|
@ -49,7 +51,7 @@ public class TaskResourceAssembler extends ResourceAssemblerSupport<Task, TaskRe
|
|||
try {
|
||||
resource = new TaskResource(task);
|
||||
resource.add(linkTo(methodOn(TaskController.class).getTask(task.getId())).withSelfRel());
|
||||
} catch (Exception e) {
|
||||
} catch (InvalidArgumentException | TaskNotFoundException | NotAuthorizedException e) {
|
||||
throw new SystemException("caught unexpected Exception.", e.getCause());
|
||||
}
|
||||
return resource;
|
||||
|
|
Loading…
Reference in New Issue