Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/microsoft/sqlserver/jdbc/DDC.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static final Object convertFloatToObject(float floatVal,
return new BigDecimal(Float.toString(floatVal));
case FLOAT:
case DOUBLE:
return (new Float(floatVal)).doubleValue();
return ((Float)floatVal).doubleValue();
case BINARY:
return convertIntToBytes(Float.floatToRawIntBits(floatVal), 4);
default:
Expand Down Expand Up @@ -275,7 +275,7 @@ static final Object convertDoubleToObject(double doubleVal,
case DOUBLE:
return doubleVal;
case REAL:
return (new Double(doubleVal)).floatValue();
return ((Double)doubleVal).floatValue();
case INTEGER:
return (int) doubleVal;
case SMALLINT: // small and tinyint returned as short
Expand Down Expand Up @@ -439,7 +439,7 @@ private static byte[] convertToBytes(BigDecimal value,
}
}
int offset = numBytes - unscaledBytes.length;
System.arraycopy(unscaledBytes, offset - offset, ret, offset, numBytes - offset);
System.arraycopy(unscaledBytes, 0, ret, offset, numBytes - offset);
return ret;
}

Expand Down
37 changes: 16 additions & 21 deletions src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ void disableSSL() {
* The mission: To close the SSLSocket and release everything that it is holding onto other than the TCP/IP socket and streams.
*
* The challenge: Simply closing the SSLSocket tries to do additional, unnecessary shutdown I/O over the TCP/IP streams that are bound to the
* socket proxy, resulting in a hang and confusing SQL Server.
* socket proxy, resulting in a not responding and confusing SQL Server.
*
* Solution: Rewire the ProxySocket's input and output streams (one more time) to closed streams. SSLSocket sees that the streams are already
* closed and does not attempt to do any further I/O on them before closing itself.
Expand Down Expand Up @@ -1870,13 +1870,11 @@ private void validateFips(final String trustStoreType,

if (isEncryptOn && !isTrustServerCertificate) {
isValid = true;
if (isValidTrustStore) {
// In case of valid trust store we need to check TrustStoreType.
if (!isValidTrustStoreType) {
isValid = false;
if (logger.isLoggable(Level.FINER))
logger.finer(toString() + "TrustStoreType is required alongside with TrustStore.");
}
if (isValidTrustStore && !isValidTrustStoreType) {
// In case of valid trust store we need to check TrustStoreType.
isValid = false;
if (logger.isLoggable(Level.FINER))
logger.finer(toString() + "TrustStoreType is required alongside with TrustStore.");
}
}

Expand Down Expand Up @@ -2547,7 +2545,7 @@ private void findSocketUsingJavaNIO(InetAddress[] inetAddrs,
+ " occured while processing the channel: " + ch);
updateSelectedException(ex, this.toString());
// close the channel pro-actively so that we do not
// hang on to network resources
// rely to network resources
ch.close();
}

Expand Down Expand Up @@ -2894,11 +2892,8 @@ void updateResult(Socket socket,
public void updateSelectedException(IOException ex,
String traceId) {
boolean updatedException = false;
if (selectedException == null) {
selectedException = ex;
updatedException = true;
}
else if ((!(ex instanceof SocketTimeoutException)) && (selectedException instanceof SocketTimeoutException)) {
if (selectedException == null ||
(!(ex instanceof SocketTimeoutException)) && (selectedException instanceof SocketTimeoutException)) {
selectedException = ex;
updatedException = true;
}
Expand Down Expand Up @@ -7553,12 +7548,12 @@ final void checkForInterrupt() throws SQLServerException {
* interrupted (0 or more packets sent with no EOM bit).
*/
final void onRequestComplete() throws SQLServerException {
assert !requestComplete;

if (logger.isLoggable(Level.FINEST))
logger.finest(this + ": request complete");

synchronized (interruptLock) {
assert !requestComplete;

if (logger.isLoggable(Level.FINEST))
logger.finest(this + ": request complete");

requestComplete = true;

// If this command was interrupted before its request was complete then
Expand Down Expand Up @@ -7630,8 +7625,8 @@ final void onResponseEOM() throws SQLServerException {
// interrupting threads. Note that it is remotely possible that the call
// to readPacket won't actually read anything if the attention ack was
// already read by TDSCommand.detach(), in which case this method could
// be called from multiple threads, leading to a benign race to clear the
// readingResponse flag.
// be called from multiple threads, leading to a benign followup process
// to clear the readingResponse flag.
if (readAttentionAck)
tdsReader.readPacket();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public boolean isRealmValid(String realm) {
validator = oracleRealmValidator;
// As explained here: https://github.com/Microsoft/mssql-jdbc/pull/40#issuecomment-281509304
// The default Oracle Resolution mechanism is not bulletproof
// If it resolves a crappy name, drop it.
// If it resolves a non-existing name, drop it.
if (!validator.isRealmValid("this.might.not.exist." + hostnameToTest)) {
// Our realm validator is well working, return it
authLogger.fine("Kerberos Realm Validator: Using Built-in Oracle Realm Validation method.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.time.OffsetTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ Connection connectInternal(Properties propsIn,
sPropKey = SQLServerDriverIntProperty.STATEMENT_POOLING_CACHE_SIZE.toString();
if (activeConnectionProperties.getProperty(sPropKey) != null && activeConnectionProperties.getProperty(sPropKey).length() > 0) {
try {
int n = new Integer(activeConnectionProperties.getProperty(sPropKey));
int n = Integer.parseInt(activeConnectionProperties.getProperty(sPropKey));
this.setStatementPoolingCacheSize(n);
}
catch (NumberFormatException e) {
Expand Down Expand Up @@ -1560,7 +1560,7 @@ Connection connectInternal(Properties propsIn,
try {
String strPort = activeConnectionProperties.getProperty(sPropKey);
if (null != strPort) {
nPort = new Integer(strPort);
nPort = Integer.parseInt(strPort);

if ((nPort < 0) || (nPort > 65535)) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidPortNumber"));
Expand Down Expand Up @@ -1640,7 +1640,7 @@ else if (0 == requestedPacketSize)
nLockTimeout = defaultLockTimeOut; // Wait forever
if (activeConnectionProperties.getProperty(sPropKey) != null && activeConnectionProperties.getProperty(sPropKey).length() > 0) {
try {
int n = new Integer(activeConnectionProperties.getProperty(sPropKey));
int n = Integer.parseInt(activeConnectionProperties.getProperty(sPropKey));
if (n >= defaultLockTimeOut)
nLockTimeout = n;
else {
Expand All @@ -1661,7 +1661,7 @@ else if (0 == requestedPacketSize)
queryTimeoutSeconds = defaultQueryTimeout; // Wait forever
if (activeConnectionProperties.getProperty(sPropKey) != null && activeConnectionProperties.getProperty(sPropKey).length() > 0) {
try {
int n = new Integer(activeConnectionProperties.getProperty(sPropKey));
int n = Integer.parseInt(activeConnectionProperties.getProperty(sPropKey));
if (n >= defaultQueryTimeout) {
queryTimeoutSeconds = n;
}
Expand All @@ -1683,7 +1683,7 @@ else if (0 == requestedPacketSize)
socketTimeoutMilliseconds = defaultSocketTimeout; // Wait forever
if (activeConnectionProperties.getProperty(sPropKey) != null && activeConnectionProperties.getProperty(sPropKey).length() > 0) {
try {
int n = new Integer(activeConnectionProperties.getProperty(sPropKey));
int n = Integer.parseInt(activeConnectionProperties.getProperty(sPropKey));
if (n >= defaultSocketTimeout) {
socketTimeoutMilliseconds = n;
}
Expand All @@ -1703,7 +1703,7 @@ else if (0 == requestedPacketSize)
sPropKey = SQLServerDriverIntProperty.SERVER_PREPARED_STATEMENT_DISCARD_THRESHOLD.toString();
if (activeConnectionProperties.getProperty(sPropKey) != null && activeConnectionProperties.getProperty(sPropKey).length() > 0) {
try {
int n = new Integer(activeConnectionProperties.getProperty(sPropKey));
int n = Integer.parseInt(activeConnectionProperties.getProperty(sPropKey));
setServerPreparedStatementDiscardThreshold(n);
}
catch (NumberFormatException e) {
Expand Down Expand Up @@ -2164,7 +2164,7 @@ ServerPortPlaceHolder primaryPermissionCheck(String primary,
connectionlogger.fine(toString() + " SQL Server port returned by SQL Browser: " + instancePort);
try {
if (null != instancePort) {
primaryPortNumber = new Integer(instancePort);
primaryPortNumber = Integer.parseInt(instancePort);

if ((primaryPortNumber < 0) || (primaryPortNumber > 65535)) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidPortNumber"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ private void setIntProperty(Properties props,
int propValue) {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "set" + propKey, propValue);
props.setProperty(propKey, new Integer(propValue).toString());
props.setProperty(propKey, ((Integer)propValue).toString());
loggerExternal.exiting(getClassNameLogging(), "set" + propKey);
}

Expand Down
Loading