Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some fixbugs cleanup #1486

Merged
merged 1 commit into from May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions pgjdbc/src/main/java/org/postgresql/core/PGStream.java
Expand Up @@ -423,8 +423,7 @@ public String receiveString() throws IOException {
* @throws IOException if a data I/O error occurs
*/
public byte[][] receiveTupleV3() throws IOException, OutOfMemoryError {
// TODO: use msgSize
int msgSize = receiveInteger4();
receiveInteger4(); // MESSAGE SIZE
int nf = receiveInteger2();
byte[][] answer = new byte[nf][];

Expand Down
Expand Up @@ -2413,7 +2413,7 @@ public void handleCommandStatus(String status, int updateCount, long insertOID)
* Receive the field descriptions from the back end.
*/
private Field[] receiveFields() throws IOException {
int msgSize = pgStream.receiveInteger4();
pgStream.receiveInteger4(); // MESSAGE SIZE
int size = pgStream.receiveInteger2();
Field[] fields = new Field[size];

Expand All @@ -2440,7 +2440,7 @@ private Field[] receiveFields() throws IOException {
}

private void receiveAsyncNotify() throws IOException {
int msglen = pgStream.receiveInteger4();
pgStream.receiveInteger4(); // MESSAGE SIZE
int pid = pgStream.receiveInteger4();
String msg = pgStream.receiveString();
String param = pgStream.receiveString();
Expand Down Expand Up @@ -2611,7 +2611,7 @@ public void readStartupMessages() throws IOException, SQLException {

public void receiveParameterStatus() throws IOException, SQLException {
// ParameterStatus
int len = pgStream.receiveInteger4();
pgStream.receiveInteger4(); // MESSAGE SIZE
String name = pgStream.receiveString();
String value = pgStream.receiveString();

Expand Down
Expand Up @@ -60,8 +60,9 @@ public static Method getFunction(String functionName) {
if (method != null) {
return method;
}
//FIXME: this probably should not use the US locale
davecramer marked this conversation as resolved.
Show resolved Hide resolved
String nameLower = functionName.toLowerCase(Locale.US);
if (nameLower == functionName) {
if (nameLower.equals(functionName)) {
// Input name was in lower case, the function is not there
return null;
}
Expand Down
6 changes: 5 additions & 1 deletion pgjdbc/src/main/java/org/postgresql/jdbc/PgArray.java
Expand Up @@ -906,14 +906,18 @@ public String toString() {

final PrimitiveArraySupport arraySupport = PrimitiveArraySupport.getArraySupport(array);
if (arraySupport != null) {
fieldString = arraySupport.toArrayString(connection.getTypeInfo().getArrayDelimiter(oid), array);
fieldString =
arraySupport.toArrayString(connection.getTypeInfo().getArrayDelimiter(oid), array);
} else {
java.sql.Array tmpArray = connection.createArrayOf(getBaseTypeName(), (Object[]) array);
fieldString = tmpArray.toString();
}
} catch (SQLException e) {
fieldString = "NULL"; // punt
}
} else {
// avoid returning null
fieldString = "NULL";
}
return fieldString;
}
Expand Down
4 changes: 2 additions & 2 deletions pgjdbc/src/main/java/org/postgresql/jdbc/TimestampUtils.java
Expand Up @@ -511,7 +511,7 @@ public synchronized Time toTime(Calendar cal, String s) throws SQLException {
}

// 2) Truncate date part so in given time zone the date would be formatted as 01/01/1970
return convertToTime(timeMillis, useCal == null ? null : useCal.getTimeZone());
return convertToTime(timeMillis, useCal.getTimeZone());
}

public synchronized Date toDate(Calendar cal, String s) throws SQLException {
Expand Down Expand Up @@ -1362,7 +1362,7 @@ private static long toPgSecs(long secs) {
int years = (int) ((secs + 15773356800L) / -3155823050L);
years++;
years -= years / 4;
secs += years * 86400;
secs += years * 86400L;
}
}

Expand Down
Expand Up @@ -132,11 +132,6 @@ public LargeObjectManager(BaseConnection conn) throws SQLException {
Statement stmt = conn.createStatement();
ResultSet res = stmt.executeQuery(sql);

if (res == null) { // NOSONAR
throw new PSQLException(GT.tr("Failed to initialize LargeObject API"),
PSQLState.SYSTEM_ERROR);
}

fp.addFunctions(res);
res.close();
stmt.close();
Expand Down
Expand Up @@ -142,7 +142,7 @@ public SingleCertValidatingFactory(String sslFactoryArg) throws GeneralSecurityE
}
}

public class SingleCertTrustManager implements X509TrustManager {
public static class SingleCertTrustManager implements X509TrustManager {
X509Certificate cert;
X509TrustManager trustManager;

Expand Down