Skip to content

Commit

Permalink
Resolved maven build warnings and java warnings regarding deprecated …
Browse files Browse the repository at this point in the history
…API (#701)

* Resolving maven warnings

* Removing jreVersion property

Does not make sense now that we use final name in the build itself. Only used in 1 place, hard-coding java version for different builds as that's what it represents anyways.

* java warnings
  • Loading branch information
rene-ye authored May 29, 2018
1 parent cbea8bd commit 1153362
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 35 deletions.
17 changes: 5 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.5.3-SNAPSHOT.${jreVersion}-preview</version>
<version>6.5.3-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Microsoft JDBC Driver for SQL Server</name>
Expand Down Expand Up @@ -130,12 +130,8 @@
<profiles>
<profile>
<id>build42</id>

<properties>
<jreVersion>jre8</jreVersion>
</properties>

<build>
<finalName>${project.artifactId}-${project.version}.jre8-preview</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down Expand Up @@ -166,13 +162,9 @@
<id>build43</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>

<properties>
<jreVersion>jre9</jreVersion>
</properties>

</activation>
<build>
<finalName>${project.artifactId}-${project.version}.jre9-preview</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down Expand Up @@ -328,6 +320,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.5</version>
<inherited>true</inherited>
<configuration>
<outputFile>outdated-dependencies.txt</outputFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3348,7 +3348,7 @@ private byte[] normalizedValue(JDBCType destJdbcType,
longValue = (long) (short) value;
break;
default:
longValue = new Long((Integer) value);
longValue = Long.valueOf((Integer) value);
}
return ByteBuffer.allocate(Long.SIZE / Byte.SIZE).order(ByteOrder.LITTLE_ENDIAN).putLong(longValue).array();

Expand All @@ -3362,7 +3362,7 @@ private byte[] normalizedValue(JDBCType destJdbcType,
longValue = (long) (short) value;
break;
case INTEGER:
longValue = new Long((Integer) value);
longValue = Long.valueOf((Integer) value);
break;
default:
longValue = (long) value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1904,25 +1904,25 @@ else if (coercion == String.class) {
return callableStatement.getString(ordinal);
}
else if (coercion == Boolean.class) {
return new Boolean(callableStatement.getBoolean(ordinal));
return Boolean.valueOf(callableStatement.getBoolean(ordinal));
}
else if (coercion == Byte.class) {
return new Byte(callableStatement.getByte(ordinal));
return Byte.valueOf(callableStatement.getByte(ordinal));
}
else if (coercion == Short.class) {
return new Short(callableStatement.getShort(ordinal));
return Short.valueOf(callableStatement.getShort(ordinal));
}
else if (coercion == Integer.class) {
return new Integer(callableStatement.getInt(ordinal));
return Integer.valueOf(callableStatement.getInt(ordinal));
}
else if (coercion == Long.class) {
return new Long(callableStatement.getLong(ordinal));
return Long.valueOf(callableStatement.getLong(ordinal));
}
else if (coercion == Float.class) {
return new Float(callableStatement.getFloat(ordinal));
return Float.valueOf(callableStatement.getFloat(ordinal));
}
else if (coercion == Double.class) {
return new Double(callableStatement.getDouble(ordinal));
return Double.valueOf(callableStatement.getDouble(ordinal));
}
else if (coercion == BigDecimal.class) {
return callableStatement.getBigDecimal(ordinal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ static void validateValues(
if(srcValue.getClass().getName().equalsIgnoreCase("java.lang.Double")){
// in case of SQL Server type Float (ie java type double), in float(n) if n is <=24 ie precsion is <=7 SQL Server type Real is returned(ie java type float)
if(destMeta.getPrecision(i) <8)
srcValue = new Float(((Double)srcValue));
srcValue = ((Double)srcValue).floatValue();
}
dstValue = dstResultSet.getObject(i);
int dstType = destMeta.getColumnType(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void testConnectionDriver() throws SQLException {
for (DriverPropertyInfo anInfoArray1 : infoArray) {
logger.fine(anInfoArray1.name);
logger.fine(anInfoArray1.description);
logger.fine(new Boolean(anInfoArray1.required).toString());
logger.fine(Boolean.valueOf(anInfoArray1.required).toString());
logger.fine(anInfoArray1.value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,13 @@ public void verifyTranslation() throws Exception {
cArg[0] = String.class;
Class<?> innerClass = Class.forName("com.microsoft.sqlserver.jdbc.JDBCSyntaxTranslator");
Constructor<?> ctor = innerClass.getDeclaredConstructor();
if (!ctor.isAccessible()) {
ctor.setAccessible(true);
}

ctor.setAccessible(true);
Object innerInstance = ctor.newInstance();
Method method = innerClass.getDeclaredMethod("translate", cArg);

if (!method.isAccessible()) {
method.setAccessible(true);
}

method.setAccessible(true);
Object str = method.invoke(innerInstance, inputSql);
assertEquals(str, outputSql, "Syntax tyranslation does not match for query: " + queryID);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public void testStatementPoolingEviction() throws SQLException {

// Add new statements to fill up the statement pool.
for (int i = 0; i < cacheSize; ++i) {
try (SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement)con.prepareStatement(query + new Integer(i).toString())) {
try (SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement)con.prepareStatement(query + String.valueOf(i))) {
pstmt.execute(); // sp_executesql
pstmt.execute(); // sp_prepexec, actual handle created and cached.
}
Expand All @@ -332,7 +332,7 @@ public void testStatementPoolingEviction() throws SQLException {
// (new statement pushes existing statement from pool into discard
// action queue).
for (int i = cacheSize; i < cacheSize + 5; ++i) {
try (SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement)con.prepareStatement(query + new Integer(i).toString())) {
try (SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement)con.prepareStatement(query + String.valueOf(i))) {
pstmt.execute(); // sp_executesql
pstmt.execute(); // sp_prepexec, actual handle created and cached.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Calendar;

import com.microsoft.sqlserver.jdbc.SQLServerResultSetMetaData;
import com.microsoft.sqlserver.testframework.DBConnection;
Expand Down Expand Up @@ -143,7 +144,11 @@ public static void compareExpectedAndActual(int dataType,
break;

case java.sql.Types.DATE:
assertTrue((((Date) expectedValue).getDate() == (((Date) actualValue).getDate())), "Unexpected datetime value");
Calendar expC = Calendar.getInstance();
expC.setTime((Date)expectedValue);
Calendar actC = Calendar.getInstance();
actC.setTime((Date)actualValue);
assertTrue(expC.get(Calendar.DAY_OF_MONTH) == actC.get(Calendar.DAY_OF_MONTH), "Unexpected datetime value");
break;

case java.sql.Types.TIME:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
Expand Down Expand Up @@ -168,15 +169,15 @@ public static BigDecimal generateDecimalNumeric(int precision,
if (r.nextBoolean()) {
n = BigInteger.TEN.pow(precision);
if (scale > 0)
return new BigDecimal(n, scale).subtract(new BigDecimal("" + Math.pow(10, -scale)).setScale(scale, BigDecimal.ROUND_HALF_UP))
return new BigDecimal(n, scale).subtract(new BigDecimal("" + Math.pow(10, -scale)).setScale(scale, RoundingMode.HALF_UP))
.negate();
else
return new BigDecimal(n, scale).subtract(new BigDecimal("1")).negate();
}
else {
n = BigInteger.TEN.pow(precision);
if (scale > 0)
return new BigDecimal(n, scale).subtract(new BigDecimal("" + Math.pow(10, -scale)).setScale(scale, BigDecimal.ROUND_HALF_UP))
return new BigDecimal(n, scale).subtract(new BigDecimal("" + Math.pow(10, -scale)).setScale(scale, RoundingMode.HALF_UP))
.negate();
else
return new BigDecimal(n, scale).subtract(new BigDecimal("1")).negate();
Expand Down Expand Up @@ -226,7 +227,7 @@ public static Double generateFloat(Integer n,
}

if (returnZero) {
return new Double(0);
return Double.valueOf(0);
}

// only 2 options: 24 or 53
Expand Down

0 comments on commit 1153362

Please sign in to comment.