Skip to content

Commit

Permalink
revert change to PGProperty.get() to keep the API the same
Browse files Browse the repository at this point in the history
delegate get(properties) to getOrDefault, added getOrNull

fix failing ArrayTest for versions below 9.1

change @code to @link for class names
  • Loading branch information
davecramer committed Oct 19, 2022
1 parent ee06e22 commit c50a9cf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 22 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/matrix.js
Expand Up @@ -199,8 +199,9 @@ matrix.setNamePattern([
matrix.exclude(row => row.ssl.value === 'yes' && isLessThan(row.pg_version, '9.3'));
matrix.exclude(row => row.scram.value === 'yes' && isLessThan(row.pg_version, '10'));
matrix.exclude(row => row.replication.value === 'yes' && isLessThan(row.pg_version, '9.6'));
//org.postgresql.test.jdbc2.ArrayTest fails using simple mode on 8.4 with malformed Array literal
matrix.exclude({query_mode: {value: 'simple'}, pg_version: '8.4'});
//org.postgresql.test.jdbc2.ArrayTest fails using simple mode for versions less than 9.0 with malformed Array literal
matrix.exclude( row => row.query_mode == 'simple' && isLessThan(row.pg_version, '9.1'));
//matrix.exclude({query_mode: {value: 'simple'}, pg_version: '8.4'});
// Microsoft Java has no distribution for 8
matrix.exclude({java_distribution: 'microsoft', java_version: '8'});
matrix.exclude({gss: {value: 'yes'}, os: ['windows-latest', 'macos-latest', 'self-hosted']})
Expand Down
51 changes: 31 additions & 20 deletions pgjdbc/src/main/java/org/postgresql/PGProperty.java
Expand Up @@ -609,7 +609,7 @@ public enum PGProperty {
"The location of the client's SSL certificate"),

/**
* Classname of the SSL Factory to use (instance of {@code javax.net.ssl.SSLSocketFactory}).
* Classname of the SSL Factory to use (instance of {@link javax.net.ssl.SSLSocketFactory}).
*/
SSL_FACTORY(
"sslfactory",
Expand All @@ -627,17 +627,16 @@ public enum PGProperty {
"Argument forwarded to constructor of SSLSocketFactory class."),

/**
* Classname of the SSL HostnameVerifier to use (instance of {@code
* javax.net.ssl.HostnameVerifier}).
* Classname of the SSL HostnameVerifier to use (instance of {@link javax.net.ssl.HostnameVerifier}).
*/
SSL_HOSTNAME_VERIFIER(
"sslhostnameverifier",
null,
"A class, implementing javax.net.ssl.HostnameVerifier that can verify the server"),

/**
* File containing the SSL Key. Default will be the file {@code postgresql.pk8} in {@code
* $HOME/.postgresql} (*nix) or {@code %APPDATA%\postgresql} (windows).
* File containing the SSL Key. Default will be the file {@code postgresql.pk8} in {@code $HOME/.postgresql} (*nix)
* or {@code %APPDATA%\postgresql} (windows).
*/
SSL_KEY(
"sslkey",
Expand Down Expand Up @@ -667,7 +666,7 @@ public enum PGProperty {


/**
* The classname instantiating {@code javax.security.auth.callback.CallbackHandler} to use.
* The classname instantiating {@link javax.security.auth.callback.CallbackHandler} to use.
*/
SSL_PASSWORD_CALLBACK(
"sslpasswordcallback",
Expand Down Expand Up @@ -762,7 +761,7 @@ public enum PGProperty {
* Factory class to instantiate factories for XML processing.
* The default factory disables external entity processing.
* Legacy behavior with external entity processing can be enabled by specifying a value of LEGACY_INSECURE.
* Or specify a custom class that implements {@code org.postgresql.xml.PGXmlFactoryFactory}.
* Or specify a custom class that implements {@link org.postgresql.xml.PGXmlFactoryFactory}.
*/
XML_FACTORY_FACTORY(
"xmlFactoryFactory",
Expand Down Expand Up @@ -851,7 +850,7 @@ public String getDescription() {
}

/**
* Returns the value of the connection parameters according to the given {@code Properties} or the
* Returns the value of the connection parameter from the given {@link Properties} or the
* default value.
*
* @param properties properties to take actual value from
Expand All @@ -862,17 +861,29 @@ public String getDescription() {
}

/**
* Returns the value of the connection parameters according to the given {@code Properties}
*
* Returns the value of the connection parameter from the given {@link Properties} or the
* default value
* @deprecated use {@link #getOrDefault(Properties)} instead
* @param properties properties to take actual value from
* @return evaluated value for this connection parameter or null
*/
@Deprecated
public @Nullable String get(Properties properties) {
return getOrDefault(properties);
}

/**
* Returns the value of the connection parameter from the given {@link Properties} or null if there
* is no default value
* @param properties properties object to get value from
* @return evaluated value for this connection parameter
*/
public @Nullable String getOrNull(Properties properties) {
return properties.getProperty(name);
}

/**
* Set the value for this connection parameter in the given {@code Properties}.
* Set the value for this connection parameter in the given {@link Properties}.
*
* @param properties properties in which the value should be set
* @param value value for this connection parameter
Expand All @@ -886,7 +897,7 @@ public void set(Properties properties, @Nullable String value) {
}

/**
* Return the boolean value for this connection parameter in the given {@code Properties}.
* Return the boolean value for this connection parameter in the given {@link Properties}.
*
* @param properties properties to take actual value from
* @return evaluated value for this connection parameter converted to boolean
Expand All @@ -896,7 +907,7 @@ public boolean getBoolean(Properties properties) {
}

/**
* Return the int value for this connection parameter in the given {@code Properties}. Prefer the
* Return the int value for this connection parameter in the given {@link Properties}. Prefer the
* use of {@link #getInt(Properties)} anywhere you can throw an {@link java.sql.SQLException}.
*
* @param properties properties to take actual value from
Expand All @@ -911,7 +922,7 @@ public int getIntNoCheck(Properties properties) {
}

/**
* Return the int value for this connection parameter in the given {@code Properties}.
* Return the int value for this connection parameter in the given {@link Properties}.
*
* @param properties properties to take actual value from
* @return evaluated value for this connection parameter converted to int
Expand All @@ -930,7 +941,7 @@ public int getInt(Properties properties) throws PSQLException {
}

/**
* Return the {@code Integer} value for this connection parameter in the given {@code Properties}.
* Return the {@link Integer} value for this connection parameter in the given {@link Properties}.
*
* @param properties properties to take actual value from
* @return evaluated value for this connection parameter converted to Integer or null
Expand All @@ -950,7 +961,7 @@ public int getInt(Properties properties) throws PSQLException {
}

/**
* Set the boolean value for this connection parameter in the given {@code Properties}.
* Set the boolean value for this connection parameter in the given {@link Properties}.
*
* @param properties properties in which the value should be set
* @param value boolean value for this connection parameter
Expand All @@ -960,7 +971,7 @@ public void set(Properties properties, boolean value) {
}

/**
* Set the int value for this connection parameter in the given {@code Properties}.
* Set the int value for this connection parameter in the given {@link Properties}.
*
* @param properties properties in which the value should be set
* @param value int value for this connection parameter
Expand All @@ -970,7 +981,7 @@ public void set(Properties properties, int value) {
}

/**
* Test whether this property is present in the given {@code Properties}.
* Test whether this property is present in the given {@link Properties}.
*
* @param properties set of properties to check current in
* @return true if the parameter is specified in the given properties
Expand All @@ -980,8 +991,8 @@ public boolean isPresent(Properties properties) {
}

/**
* Convert this connection parameter and the value read from the given {@code Properties} into a
* {@code DriverPropertyInfo}.
* Convert this connection parameter and the value read from the given {@link Properties} into a
* {@link DriverPropertyInfo}.
*
* @param properties properties to take actual value from
* @return a DriverPropertyInfo representing this connection parameter
Expand Down

0 comments on commit c50a9cf

Please sign in to comment.