Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 34a63e0

Browse files
pesseSamuel Nitsche
authored andcommitted
Little bit of refactoring
we don't want to have another open connection, do we?
1 parent 091dbea commit 34a63e0

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/main/java/org/utplsql/cli/RunCommand.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ public List<String> getTestPaths() {
9191
public int run() throws Exception {
9292
final ConnectionInfo ci = getConnectionInfo();
9393

94-
// First of all do a compatibility check and fail-fast
95-
checkFrameworkCompatibility(ci);
9694

9795
final List<ReporterOptions> reporterOptionsList = getReporterOptionsList();
9896
final List<String> testPaths = getTestPaths();
@@ -118,6 +116,10 @@ public int run() throws Exception {
118116

119117
// Do the reporters initialization, so we can use the id to run and gather results.
120118
try (Connection conn = ci.getConnection()) {
119+
120+
// First of all do a compatibility check and fail-fast
121+
checkFrameworkCompatibility(conn);
122+
121123
for (ReporterOptions ro : reporterOptionsList) {
122124
Reporter reporter = ReporterFactory.createReporter(ro.getReporterName());
123125
reporter.init(conn);
@@ -212,11 +214,16 @@ public List<ReporterOptions> getReporterOptionsList() {
212214
return reporterOptionsList;
213215
}
214216

215-
private void checkFrameworkCompatibility(ConnectionInfo ci) throws SQLException {
217+
/** Checks whether cli is compatible with the database framework
218+
*
219+
* @param conn Active Connection
220+
* @throws SQLException
221+
*/
222+
private void checkFrameworkCompatibility(Connection conn) throws SQLException {
216223

217224
if ( !skipCompatibilityCheck ) {
218225
try {
219-
DBHelper.failOnVersionCompatibilityCheckFailed(ci.getConnection());
226+
DBHelper.failOnVersionCompatibilityCheckFailed(conn);
220227
} catch (DatabaseNotCompatibleException e) {
221228
System.out.println(e.getMessage());
222229

0 commit comments

Comments
 (0)