Skip to content

Commit

Permalink
Clean up warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
soklakov committed Jan 12, 2016
1 parent b465b53 commit 53f91cc
Show file tree
Hide file tree
Showing 23 changed files with 114 additions and 99 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
The MySQL Connector/J is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors.
Expand Down Expand Up @@ -135,6 +135,7 @@ public boolean supportsAggressiveRelease() {
return false;
}

@SuppressWarnings("rawtypes")
public boolean isUnwrappableAs(Class unwrapType) {
return false;
}
Expand Down
13 changes: 8 additions & 5 deletions src/com/mysql/fabric/jdbc/FabricMySQLConnectionProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ public FabricMySQLConnectionProxy(Properties props) throws SQLException {
this.log = LogFactory.getLogger(getLogger(), "FabricMySQLConnectionProxy", null);
}

private boolean intercepting = false; // prevent recursion

/**
* Deal with an exception thrown on an underlying connection. We only consider connection exceptions (SQL State 08xxx). We internally handle a possible
* failover situation.
Expand All @@ -208,10 +206,10 @@ public FabricMySQLConnectionProxy(Properties props) throws SQLException {
* @param conn
* @param group
* @param hostname
* @param port
* @param portNumber
* @throws FabricCommunicationException
*/
synchronized SQLException interceptException(SQLException sqlEx, Connection conn, String groupName, String hostname, String port)
synchronized SQLException interceptException(SQLException sqlEx, Connection conn, String groupName, String hostname, String portNumber)
throws FabricCommunicationException {
// we are only concerned with connection failures, skip anything else
if (sqlEx.getSQLState() != null && !(sqlEx.getSQLState().startsWith("08")
Expand All @@ -220,7 +218,7 @@ synchronized SQLException interceptException(SQLException sqlEx, Connection conn
}

// find the Server corresponding to this connection
Server currentServer = this.serverGroup.getServer(hostname + ":" + port);
Server currentServer = this.serverGroup.getServer(hostname + ":" + portNumber);

// we have already failed over or dealt with this connection, let the exception propagate
if (currentServer == null) {
Expand Down Expand Up @@ -3024,6 +3022,11 @@ public Properties getClientInfo() {
return null;
}

/**
*
* @param name
* @return
*/
public String getClientInfo(String name) {
return null;
}
Expand Down
5 changes: 4 additions & 1 deletion src/com/mysql/fabric/proto/xmlrpc/DigestAuthentication.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
*/
public class DigestAuthentication {

private static Random random = new Random();

/**
* Get the digest challenge header by connecting to the resource
* with no credentials.
Expand Down Expand Up @@ -163,10 +165,11 @@ public static Map<String, String> parseDigestChallenge(String headerValue) {
* value used in the digest calculation. Same as Python. (no
* motivation given for this algorithm)
*/
@SuppressWarnings("deprecation")
public static String generateCnonce(String nonce, String nc) {
// Random string, keep it in basic printable ASCII range
byte buf[] = new byte[8];
new Random().nextBytes(buf);
random.nextBytes(buf);
for (int i = 0; i < 8; ++i) {
buf[i] = (byte) (0x20 + (buf[i] % 95));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
The MySQL Connector/J is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors.
Expand Down Expand Up @@ -72,8 +72,8 @@ private Object unwrapValue(Value v) {
return v.getValue();
}

private List methodResponseArrayToList(Array array) {
List result = new ArrayList();
private List<Object> methodResponseArrayToList(Array array) {
List<Object> result = new ArrayList<Object>();
for (Value v : array.getData().getValue()) {
result.add(unwrapValue(v));
}
Expand All @@ -88,7 +88,7 @@ public void clearHeader(String name) {
this.xmlRpcClient.clearHeader(name);
}

public List call(String methodName, Object args[]) throws FabricCommunicationException {
public List<Object> call(String methodName, Object args[]) throws FabricCommunicationException {
MethodCall methodCall = new MethodCall();
Params p = new Params();
if (args == null) {
Expand Down
19 changes: 6 additions & 13 deletions src/com/mysql/jdbc/ConnectionImpl.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
The MySQL Connector/J is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors.
Expand Down Expand Up @@ -2891,6 +2891,7 @@ public int getMaxBytesPerChar(String javaCharsetName) throws SQLException {
public int getMaxBytesPerChar(Integer charsetIndex, String javaCharsetName) throws SQLException {

String charset = null;
int res = 1;

try {
// if we can get it by charsetIndex just doing it
Expand Down Expand Up @@ -2922,7 +2923,7 @@ public int getMaxBytesPerChar(Integer charsetIndex, String javaCharsetName) thro
}

if (mblen != null) {
return mblen.intValue();
res = mblen.intValue();
}
} catch (SQLException ex) {
throw ex;
Expand All @@ -2932,7 +2933,7 @@ public int getMaxBytesPerChar(Integer charsetIndex, String javaCharsetName) thro
throw sqlEx;
}

return 1; // we don't know
return res;
}

/**
Expand Down Expand Up @@ -3566,9 +3567,7 @@ public boolean isInGlobalTx() {
* the list.
*/
public boolean isMasterConnection() {
synchronized (getConnectionMutex()) {
return false; // handled higher up
}
return false; // handled higher up
}

/**
Expand Down Expand Up @@ -3710,8 +3709,6 @@ public boolean isServerTzUTC() {
return this.isServerTzUTC;
}

private boolean usingCachedConfig = false;

private void createConfigCacheIfNeeded() throws SQLException {
synchronized (getConnectionMutex()) {
if (this.serverConfigCache != null) {
Expand Down Expand Up @@ -3796,7 +3793,6 @@ private void loadServerVariables() throws SQLException {

if (cachedServerVersion != null && this.io.getServerVersion() != null && cachedServerVersion.equals(this.io.getServerVersion())) {
this.serverVariables = cachedVariableMap;
this.usingCachedConfig = true;

return;
}
Expand Down Expand Up @@ -3886,7 +3882,6 @@ private void loadServerVariables() throws SQLException {

this.serverConfigCache.put(getURL(), this.serverVariables);

this.usingCachedConfig = true;
}
} catch (SQLException e) {
throw e;
Expand Down Expand Up @@ -4964,9 +4959,7 @@ void forEach(Extension each) throws SQLException {
* The failedOver to set.
*/
public void setFailedOver(boolean flag) {
synchronized (getConnectionMutex()) {
// handled higher up
}
// handled higher up
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/com/mysql/jdbc/MultiHostMySQLConnection.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
The MySQL Connector/J is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors.
Expand Down Expand Up @@ -88,6 +88,7 @@ public void checkClosed() throws SQLException {
getActiveMySQLConnection().checkClosed();
}

@Deprecated
public void clearHasTriedMaster() {
getActiveMySQLConnection().clearHasTriedMaster();
}
Expand Down Expand Up @@ -1856,6 +1857,7 @@ public boolean hasSameProperties(Connection c) {
return getActiveMySQLConnection().hasSameProperties(c);
}

@Deprecated
public boolean hasTriedMaster() {
return getActiveMySQLConnection().hasTriedMaster();
}
Expand Down Expand Up @@ -2080,6 +2082,7 @@ public void setInGlobalTx(boolean flag) {
getActiveMySQLConnection().setInGlobalTx(flag);
}

@Deprecated
public void setPreferSlaveDuringFailover(boolean flag) {
getActiveMySQLConnection().setPreferSlaveDuringFailover(flag);
}
Expand Down
1 change: 1 addition & 0 deletions src/com/mysql/jdbc/NonRegisteringDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ public boolean jdbcCompliant() {
return false;
}

@SuppressWarnings("deprecation")
public Properties parseURL(String url, Properties defaults) throws java.sql.SQLException {
Properties urlProps = (defaults != null) ? new Properties(defaults) : new Properties();

Expand Down
4 changes: 2 additions & 2 deletions src/com/mysql/jdbc/PreparedStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -4216,7 +4216,7 @@ private void setTimestampInternal(int parameterIndex, Timestamp x, Calendar targ
x = TimeUtil.changeTimezone(this.connection, sessionCalendar, targetCalendar, x, tz, this.connection.getServerTimezoneTZ(), rollForward);

if (this.connection.getUseSSPSCompatibleTimezoneShift()) {
doSSPSCompatibleTimezoneShift(parameterIndex, x, sessionCalendar);
doSSPSCompatibleTimezoneShift(parameterIndex, x);
} else {
synchronized (this) {
if (this.tsdf == null) {
Expand Down Expand Up @@ -4303,7 +4303,7 @@ private void newSetDateInternal(int parameterIndex, Date x, Calendar targetCalen
}
}

private void doSSPSCompatibleTimezoneShift(int parameterIndex, Timestamp x, Calendar sessionCalendar) throws SQLException {
private void doSSPSCompatibleTimezoneShift(int parameterIndex, Timestamp x) throws SQLException {
synchronized (checkClosed().getConnectionMutex()) {
Calendar sessionCalendar2 = (this.connection.getUseJDBCCompliantTimezoneShift()) ? this.connection.getUtcCalendar()
: getCalendarInstanceForSessionOrNew();
Expand Down
1 change: 0 additions & 1 deletion src/com/mysql/jdbc/SQLError.java
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,6 @@ public static String createLinkFailureMessageBasedOnHeuristics(MySQLConnection c
// Attempt to determine the reason for the underlying exception (we can only make a best-guess here)
//

Throwable cause;
if (underlyingException instanceof BindException) {
if (conn.getLocalSocketAddress() != null && !Util.interfaceExists(conn.getLocalSocketAddress())) {
exceptionMessageBuf.append(Messages.getString("CommunicationsException.LocalSocketAddressNotAvailable"));
Expand Down
4 changes: 1 addition & 3 deletions src/com/mysql/jdbc/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1801,9 +1801,7 @@ public static String stripComments(String src, String stringOpens, String string
try {
while ((currentChar = sourceReader.read()) != -1) {

if (false && currentChar == '\\') {
escaped = !escaped;
} else if (markerTypeFound != -1 && currentChar == stringCloses.charAt(markerTypeFound) && !escaped) {
if (markerTypeFound != -1 && currentChar == stringCloses.charAt(markerTypeFound) && !escaped) {
contextMarker = Character.MIN_VALUE;
markerTypeFound = -1;
} else if ((ind = stringOpens.indexOf(currentChar)) != -1 && !escaped && contextMarker == Character.MIN_VALUE) {
Expand Down
16 changes: 1 addition & 15 deletions src/com/mysql/jdbc/jdbc2/optional/CallableStatementWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,6 @@ public float getFloat(int parameterIndex) throws SQLException {
return 0;
}

/*
* (non-Javadoc)
*
* @see java.sql.CallableStatement#getDouble(int)
*/
public double getDouble(int parameterIndex) throws SQLException {
try {
if (this.wrappedStmt != null) {
Expand All @@ -291,11 +286,7 @@ public double getDouble(int parameterIndex) throws SQLException {
return 0;
}

/*
* (non-Javadoc)
*
* @see java.sql.CallableStatement#getBigDecimal(int, int)
*/
@Deprecated
public BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException {
try {
if (this.wrappedStmt != null) {
Expand Down Expand Up @@ -329,11 +320,6 @@ public byte[] getBytes(int parameterIndex) throws SQLException {
return null;
}

/*
* (non-Javadoc)
*
* @see java.sql.CallableStatement#getDate(int)
*/
public Date getDate(int parameterIndex) throws SQLException {
try {
if (this.wrappedStmt != null) {
Expand Down
5 changes: 4 additions & 1 deletion src/com/mysql/jdbc/jdbc2/optional/ConnectionWrapper.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
The MySQL Connector/J is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors.
Expand Down Expand Up @@ -806,6 +806,7 @@ public void changeUser(String userName, String newPassword) throws SQLException
}
}

@Deprecated
public void clearHasTriedMaster() {
this.mc.clearHasTriedMaster();
}
Expand Down Expand Up @@ -902,6 +903,7 @@ public String getStatementComment() {
return this.mc.getStatementComment();
}

@Deprecated
public boolean hasTriedMaster() {
return this.mc.hasTriedMaster();
}
Expand Down Expand Up @@ -1005,6 +1007,7 @@ public void setFailedOver(boolean flag) {

}

@Deprecated
public void setPreferSlaveDuringFailover(boolean flag) {
this.mc.setPreferSlaveDuringFailover(flag);
}
Expand Down
4 changes: 2 additions & 2 deletions src/com/mysql/jdbc/jdbc2/optional/WrapperBase.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
The MySQL Connector/J is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors.
Expand Down Expand Up @@ -57,7 +57,7 @@ protected void checkAndFireConnectionError(SQLException sqlEx) throws SQLExcepti
throw sqlEx;
}

protected Map unwrappedInterfaces = null;
protected Map<Class<?>, Object> unwrappedInterfaces = null;
protected ExceptionInterceptor exceptionInterceptor;

protected WrapperBase(MysqlPooledConnection pooledConnection) {
Expand Down
3 changes: 1 addition & 2 deletions src/demo/fabric/EmployeesDataSource.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
The MySQL Connector/J is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors.
Expand All @@ -24,7 +24,6 @@
package demo.fabric;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
Expand Down
10 changes: 9 additions & 1 deletion src/testsuite/BaseTestCase.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
The MySQL Connector/J is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors.
Expand Down Expand Up @@ -62,6 +62,14 @@ public abstract class BaseTestCase extends TestCase {

private final static String NO_MULTI_HOST_PROPERTY_NAME = "com.mysql.jdbc.testsuite.no-multi-hosts-tests";

// next variables disable some tests
protected boolean DISABLED_testBug15121 = true; // TODO needs to be fixed on server
protected boolean DISABLED_testBug7033 = true; // TODO disabled for unknown reason
protected boolean DISABLED_testBug2654 = true; // TODO check if it's still a server-level bug
protected boolean DISABLED_testBug5136 = true; // TODO disabled for unknown reason
protected boolean DISABLED_testBug65503 = true; // TODO disabled for unknown reason
protected boolean DISABLED_testContention = true; // TODO disabled for unknown reason

/**
* JDBC URL, initialized from com.mysql.jdbc.testsuite.url system property,
* or defaults to jdbc:mysql:///test
Expand Down
Loading

0 comments on commit 53f91cc

Please sign in to comment.