Skip to content

Commit 93c8e5d

Browse files
committed
Some more minor refactoring
1 parent 554c71b commit 93c8e5d

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ public class ReportersCommand implements ICommand {
2020
description = ConnectionInfo.COMMANDLINE_PARAM_DESCRIPTION)
2121
private List<ConnectionInfo> connectionInfoList = new ArrayList<>();
2222

23-
public ConnectionInfo getConnectionInfo() {
24-
if ( connectionInfoList != null && connectionInfoList.size() > 0 )
25-
return connectionInfoList.get(0);
26-
else
27-
return null;
23+
private ConnectionInfo getConnectionInfo() {
24+
assert connectionInfoList != null;
25+
assert connectionInfoList.size() > 0;
26+
assert connectionInfoList.get(0) != null;
27+
28+
return connectionInfoList.get(0);
2829
}
2930

3031
@Override

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import javax.sql.DataSource;
1212
import java.sql.Connection;
13+
import java.sql.SQLException;
1314
import java.util.ArrayList;
1415
import java.util.List;
1516

@@ -34,7 +35,18 @@ public int run() {
3435
System.out.println(CliVersionInfo.getInfo());
3536
System.out.println(JavaApiVersionInfo.getInfo());
3637

37-
ConnectionInfo ci = getConnectionInfo();
38+
try {
39+
writeUtPlsqlVersion(getConnectionInfo());
40+
}
41+
catch (SQLException e) {
42+
e.printStackTrace();
43+
return 1;
44+
}
45+
46+
return 0;
47+
}
48+
49+
private void writeUtPlsqlVersion( ConnectionInfo ci ) throws SQLException {
3850
if ( ci != null ) {
3951

4052
DataSource dataSource = DataSourceProvider.getDataSource(ci, 1);
@@ -46,13 +58,7 @@ public int run() {
4658
catch ( UtPLSQLNotInstalledException e ) {
4759
System.out.println("utPLSQL framework is not installed in database.");
4860
}
49-
catch ( Exception e ) {
50-
e.printStackTrace();
51-
return 1;
52-
}
5361
}
54-
55-
return 0;
5662
}
5763

5864
@Override

0 commit comments

Comments
 (0)