Skip to content

Commit 6d12174

Browse files
committed
Added ParametersAreNonnullByDefault
1 parent 5ee67a9 commit 6d12174

11 files changed

+25
-18
lines changed

pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.utplsql</groupId>
66
<artifactId>java-api</artifactId>
7-
<version>3.1.1.1-SNAPSHOT</version>
7+
<version>3.1.2-SNAPSHOT</version>
88
<packaging>jar</packaging>
99

1010
<name>utPLSQL-java-api</name>
@@ -36,6 +36,11 @@
3636
<version>12.2.0.1</version>
3737
<scope>compile</scope>
3838
</dependency>
39+
<dependency>
40+
<groupId>com.google.code.findbugs</groupId>
41+
<artifactId>jsr305</artifactId>
42+
<version>3.0.2</version>
43+
</dependency>
3944
<dependency>
4045
<groupId>org.junit.jupiter</groupId>
4146
<artifactId>junit-jupiter-api</artifactId>

src/main/java/org/utplsql/api/DBHelper.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ private DBHelper() {}
2020
* @throws SQLException any database error
2121
*/
2222
public static String newSysGuid(Connection conn) throws SQLException {
23-
assert conn != null;
2423
try (CallableStatement callableStatement = conn.prepareCall("BEGIN ? := sys_guid(); END;")) {
2524
callableStatement.registerOutParameter(1, OracleTypes.RAW);
2625
callableStatement.executeUpdate();
@@ -38,7 +37,6 @@ public static String newSysGuid(Connection conn) throws SQLException {
3837
*/
3938
@Deprecated
4039
public static String getCurrentSchema(Connection conn) throws SQLException {
41-
assert conn != null;
4240
try (CallableStatement callableStatement = conn.prepareCall("BEGIN ? := sys_context('userenv', 'current_schema'); END;")) {
4341
callableStatement.registerOutParameter(1, Types.VARCHAR);
4442
callableStatement.executeUpdate();
@@ -55,7 +53,6 @@ public static String getCurrentSchema(Connection conn) throws SQLException {
5553
*/
5654
@Deprecated
5755
public static Version getDatabaseFrameworkVersion( Connection conn ) throws SQLException {
58-
Objects.requireNonNull(conn);
5956
Version result = new Version("");
6057
try (PreparedStatement stmt = conn.prepareStatement("select ut_runner.version() from dual"))
6158
{
@@ -84,7 +81,6 @@ public static Version getDatabaseFrameworkVersion( Connection conn ) throws SQLE
8481
*/
8582
@Deprecated
8683
public static String getOracleDatabaseVersion( Connection conn ) throws SQLException {
87-
assert conn != null;
8884
String result = null;
8985
try (PreparedStatement stmt = conn.prepareStatement("select version from product_component_version where product like 'Oracle Database%'"))
9086
{
@@ -102,7 +98,6 @@ public static String getOracleDatabaseVersion( Connection conn ) throws SQLExcep
10298
* @param conn the connection
10399
*/
104100
public static void enableDBMSOutput(Connection conn) {
105-
assert conn != null;
106101
try (CallableStatement call = conn.prepareCall("BEGIN dbms_output.enable(NULL); END;")) {
107102
call.execute();
108103
} catch (SQLException e) {
@@ -115,7 +110,6 @@ public static void enableDBMSOutput(Connection conn) {
115110
* @param conn the connection
116111
*/
117112
public static void disableDBMSOutput(Connection conn) {
118-
assert conn != null;
119113
try (CallableStatement call = conn.prepareCall("BEGIN dbms_output.disable(); END;")) {
120114
call.execute();
121115
} catch (SQLException e) {

src/main/java/org/utplsql/api/EnvironmentVariableUtil.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.utplsql.api;
22

3+
import javax.annotation.Nullable;
4+
35
/**
46
* This class provides an easy way to get environmental variables.
57
* This is mainly to improve testability but also to standardize the way how utPLSQL API and CLI read from
@@ -37,7 +39,7 @@ public static String getEnvValue(String key) {
3739
* @param defaultValue Default value if nothing found
3840
* @return Environment value or defaultValue
3941
*/
40-
public static String getEnvValue(String key, String defaultValue) {
42+
public static String getEnvValue(String key, @Nullable String defaultValue) {
4143

4244
String val = System.getProperty(key);
4345
if (val == null || val.isEmpty()) val = System.getenv(key);

src/main/java/org/utplsql/api/JavaApiVersionInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ private JavaApiVersionInfo() { }
1111

1212
private static final String BUILD_NO = "123";
1313
private static final String MAVEN_PROJECT_NAME = "utPLSQL-java-api";
14-
private static final String MAVEN_PROJECT_VERSION = "3.1.1.1-SNAPSHOT";
14+
private static final String MAVEN_PROJECT_VERSION = "3.1.2-SNAPSHOT";
1515

1616
public static String getVersion() {
1717
return MAVEN_PROJECT_VERSION + "." + BUILD_NO;

src/main/java/org/utplsql/api/TestRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public TestRunner colorConsole(boolean colorConsole) {
5858
}
5959

6060
public TestRunner addReporterList(List<Reporter> reporterList) {
61-
if (options.reporterList != null) options.reporterList.addAll(reporterList);
61+
options.reporterList.addAll(reporterList);
6262
return this;
6363
}
6464

src/main/java/org/utplsql/api/Version.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.utplsql.api.exception.InvalidVersionException;
44

5+
import javax.annotation.Nullable;
56
import java.util.regex.Matcher;
67
import java.util.regex.Pattern;
78

@@ -105,7 +106,7 @@ public String getNormalizedString()
105106
return "invalid";
106107
}
107108

108-
private int compareToWithNulls( Integer i1, Integer i2 ) {
109+
private int compareToWithNulls(@Nullable Integer i1, @Nullable Integer i2 ) {
109110
if ( i1 == null && i2 == null )
110111
return 0;
111112
else if ( i1 == null )

src/main/java/org/utplsql/api/db/DatabaseInformation.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.utplsql.api.Version;
44

5+
import javax.annotation.Nullable;
56
import java.sql.Connection;
67
import java.sql.SQLException;
78

@@ -17,5 +18,5 @@ public interface DatabaseInformation {
1718

1819
String getCurrentSchema( Connection conn ) throws SQLException;
1920

20-
int frameworkCompatibilityCheck(Connection conn, String requested, String current) throws SQLException;
21+
int frameworkCompatibilityCheck(Connection conn, String requested, @Nullable String current) throws SQLException;
2122
}

src/main/java/org/utplsql/api/db/DefaultDatabaseInformation.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import org.utplsql.api.Version;
44
import org.utplsql.api.exception.UtPLSQLNotInstalledException;
55

6+
import javax.annotation.Nullable;
67
import java.sql.*;
78
import java.util.Objects;
89

910
public class DefaultDatabaseInformation implements DatabaseInformation {
1011

1112
@Override
1213
public Version getUtPlsqlFrameworkVersion(Connection conn) throws SQLException {
13-
Objects.requireNonNull(conn);
1414
Version result = new Version("");
1515
try (PreparedStatement stmt = conn.prepareStatement("select ut_runner.version() from dual"))
1616
{
@@ -32,7 +32,6 @@ public Version getUtPlsqlFrameworkVersion(Connection conn) throws SQLException {
3232

3333
@Override
3434
public String getOracleVersion(Connection conn) throws SQLException {
35-
Objects.requireNonNull(conn);
3635
String result = null;
3736
try (PreparedStatement stmt = conn.prepareStatement("select version from product_component_version where product like 'Oracle Database%'"))
3837
{
@@ -47,7 +46,6 @@ public String getOracleVersion(Connection conn) throws SQLException {
4746

4847
@Override
4948
public String getCurrentSchema(Connection conn) throws SQLException {
50-
Objects.requireNonNull(conn);
5149
try (CallableStatement callableStatement = conn.prepareCall("BEGIN ? := sys_context('userenv', 'current_schema'); END;")) {
5250
callableStatement.registerOutParameter(1, Types.VARCHAR);
5351
callableStatement.executeUpdate();
@@ -56,7 +54,7 @@ public String getCurrentSchema(Connection conn) throws SQLException {
5654
}
5755

5856
@Override
59-
public int frameworkCompatibilityCheck(Connection conn, String requested, String current) throws SQLException {
57+
public int frameworkCompatibilityCheck(Connection conn, String requested, @Nullable String current) throws SQLException {
6058
try(CallableStatement callableStatement = conn.prepareCall("BEGIN ? := ut_runner.version_compatibility_check(?, ?); END;")) {
6159
callableStatement.registerOutParameter(1, Types.SMALLINT);
6260
callableStatement.setString(2, requested);

src/main/java/org/utplsql/api/exception/SomeTestsFailedException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.utplsql.api.exception;
22

3+
import javax.annotation.Nullable;
34
import java.sql.SQLException;
45

56
/**
@@ -9,7 +10,7 @@ public class SomeTestsFailedException extends SQLException {
910

1011
public static final int ERROR_CODE = 20213;
1112

12-
public SomeTestsFailedException(String reason, Throwable cause) {
13+
public SomeTestsFailedException(String reason, @Nullable Throwable cause) {
1314
super(reason, cause);
1415
}
1516

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@ParametersAreNonnullByDefault
2+
package org.utplsql.api;
3+
4+
import javax.annotation.ParametersAreNonnullByDefault;

src/main/java/org/utplsql/api/reporter/ReporterFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import oracle.sql.ORADataFactory;
66
import org.utplsql.api.compatibility.CompatibilityProxy;
77

8+
import javax.annotation.Nullable;
89
import java.sql.SQLException;
910
import java.sql.Struct;
1011
import java.util.HashMap;
@@ -74,7 +75,7 @@ public synchronized boolean hasRegisteredFactoryMethodFor( String reporterName )
7475
* @param attributes attributes from STRUCT
7576
* @return A reporter
7677
*/
77-
public Reporter createReporter(String reporterName, Object[] attributes) {
78+
public Reporter createReporter(String reporterName, @Nullable Object[] attributes) {
7879

7980
reporterName = reporterName.toUpperCase();
8081
BiFunction<String, Object[], ? extends Reporter> supplier = DefaultReporter::new;

0 commit comments

Comments
 (0)