Handle NumberFormatException thrown in DatabaseImportController (#3116)

* Handle NumberFormatException thrown in DatabaseImportController

* Update extensions/database/src/com/google/refine/extension/database/DatabaseImportController.java

Co-authored-by: Antonin Delpeuch <antonin@delpeuch.eu>

* Update DatabaseImportController.java

Add space just before the catch block

Co-authored-by: Antonin Delpeuch <antonin@delpeuch.eu>
This commit is contained in:
Gomaa 2020-08-25 20:40:49 +02:00 committed by GitHub
parent 5ca5f3cb7b
commit ded6ca07d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -450,7 +450,11 @@ public class DatabaseImportController implements ImportingController {
jdbcConfig.setConnectionName(request.getParameter("connectionName")); jdbcConfig.setConnectionName(request.getParameter("connectionName"));
jdbcConfig.setDatabaseType(request.getParameter("databaseType")); jdbcConfig.setDatabaseType(request.getParameter("databaseType"));
jdbcConfig.setDatabaseHost(request.getParameter("databaseServer")); jdbcConfig.setDatabaseHost(request.getParameter("databaseServer"));
jdbcConfig.setDatabasePort(Integer.parseInt(request.getParameter("databasePort"))); try {
jdbcConfig.setDatabasePort(Integer.parseInt(request.getParameter("databasePort")));
} catch(NumberFormatException nfE) {
logger.error("getQueryInfo :: invalid database port ::{}", nfE);
}
jdbcConfig.setDatabaseUser(request.getParameter("databaseUser")); jdbcConfig.setDatabaseUser(request.getParameter("databaseUser"));
jdbcConfig.setDatabasePassword(request.getParameter("databasePassword")); jdbcConfig.setDatabasePassword(request.getParameter("databasePassword"));
jdbcConfig.setDatabaseName(request.getParameter("initialDatabase")); jdbcConfig.setDatabaseName(request.getParameter("initialDatabase"));
@ -462,7 +466,7 @@ public class DatabaseImportController implements ImportingController {
} }
if (jdbcConfig.getDatabaseHost() == null || jdbcConfig.getDatabaseName() == null if (jdbcConfig.getDatabaseHost() == null || jdbcConfig.getDatabaseName() == null
|| jdbcConfig.getDatabasePassword() == null || jdbcConfig.getDatabaseType() == null || jdbcConfig.getDatabasePassword() == null || jdbcConfig.getDatabaseType() == null
|| jdbcConfig.getDatabaseUser() == null || query == null) { || jdbcConfig.getDatabaseUser() == null || query == null || jdbcConfig.getDatabasePort() == 0) {
if(logger.isDebugEnabled()) { if(logger.isDebugEnabled()) {
logger.debug("Missing Database Configuration::{}", jdbcConfig); logger.debug("Missing Database Configuration::{}", jdbcConfig);
} }