PostgisNGDataStoreFactory minor bugs (connection isn't assigned and DB drop wrong exception message)

Description

Line 190 of PostgisNGDataStoreFactory contains:

Connection cx = null;
boolean canConnect = true;
try
{
ds.getConnection();
}
catch (SQLException e)
{
canConnect = false;
}
finally
{
closer.closeSafe(cx);
}

As you can see, the finally block always try to close a null connection which results in doing nothing.

The fix should be cx = ds.getConnection right after the "try" line.

Finally,
line 295 contains:
} catch (SQLException e) {
throw new IOException("Failed to create the target database", e);

Even if we are doing a drop instead of a create.
So I'll change the exception with:
Failed to drop the target database

I'm going to create a pull request with these small fixes.

Environment

None

Activity

Show:
codehaus
April 10, 2015, 3:19 PM

CodeHaus Comment From: dany111 - Time: Fri, 17 Jan 2014 09:13:05 -0600
---------------------
Pull request:

<a href="https://github.com/geotools/geotools/pull/348">https://github.com/geotools/geotools/pull/348</a>

codehaus
April 10, 2015, 3:19 PM

CodeHaus Comment From: dany111 - Time: Fri, 17 Jan 2014 09:14:23 -0600
---------------------
Fixed on 11.x.

Backport on 10.x once Postgis create and drop capabilities are backported too

Andrea Aime
February 15, 2017, 11:34 AM

Mass transitioning all resolved issues that have not been updated in the last month to closed state

Fixed

Assignee

Unassigned

Reporter

codehaus

Triage

None

Components

Fix versions

Priority

Low
Configure