Skip to content

Commit

Permalink
FORGE-2684: Exception should be reset to null if connection succeeds
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Sep 28, 2016
1 parent 4f9c069 commit 826b89a
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
*/
public class DatabaseTableSelectionStep implements UIWizardStep
{

private static final String LAST_USED_CONNECTION_PROPERTIES = "ConnectionProperties";
private UISelectOne<String> databaseCatalog;
private UISelectOne<String> databaseSchema;
private UISelectMany<String> databaseTables;
Expand Down Expand Up @@ -125,8 +127,8 @@ private boolean connectionInfoHasChanged(UIContext context)
{
Map<Object, Object> attributeMap = context.getAttributeMap();
GenerateEntitiesCommandDescriptor descriptor = getDescriptor(context);
Properties currentConnectionProperties = (Properties) attributeMap.get("DatabaseTableProperties");
return !Objects.equals(descriptor.getConnectionProperties(), currentConnectionProperties);
Properties lastUsedConnectionProperties = (Properties) attributeMap.get(LAST_USED_CONNECTION_PROPERTIES);
return !Objects.equals(descriptor.getConnectionProperties(), lastUsedConnectionProperties);
}

@Override
Expand All @@ -146,7 +148,7 @@ public void validate(UIValidationContext context)
message = String.format("%s during validation. Check logs for more information",
exception.getClass().getName());
}
context.addValidationError(databaseTables, exception.getMessage());
context.addValidationError(databaseTables, message);
}
}
else
Expand Down Expand Up @@ -278,14 +280,17 @@ private synchronized Database getDatabase(UIContext context)
try
{
database = JDBCUtils.getDatabaseInfo(descriptor);
exception = null;
attributeMap.put(Database.class.getName(), database);
attributeMap.put(LAST_USED_CONNECTION_PROPERTIES, descriptor.getConnectionProperties());
}
catch (Exception e)
{
attributeMap.remove(Database.class.getName());
attributeMap.remove(LAST_USED_CONNECTION_PROPERTIES);
logger.log(Level.SEVERE, "Error while fetching the DB info", exception);
exception = e;
}
attributeMap.put(Database.class.getName(), database);
attributeMap.put("DatabaseTableProperties", descriptor.getConnectionProperties());
}
return database;
}
Expand Down

0 comments on commit 826b89a

Please sign in to comment.