Skip to content

Commit

Permalink
chore: run "Unnecessary boxing" inspection in IDEA
Browse files Browse the repository at this point in the history
new Double(..), new Integer(..) have been deprecated for removal
  • Loading branch information
vlsi committed Mar 11, 2023
1 parent ed866f0 commit 61aee4d
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public void testSetPrimitiveArraysObjects() throws SQLException {
Assert.assertEquals("fa\"b", strarr[1]);

try {
arraySupport.createArrayOf("int4", Integer.valueOf(1));
arraySupport.createArrayOf("int4", 1);
fail("not an array");
} catch (PSQLException e) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,15 +619,15 @@ public void testBatchWithAlternatingAndUnknownTypesN(int numPreliminaryInserts)
ps.executeBatch();
}

ps.setObject(1, new Double(43));
ps.setObject(1, 43.0);
ps.setObject(2, new Date(43));
ps.addBatch();
ps.setNull(1, Types.SMALLINT);
ps.setObject(2, new Date(44));
ps.addBatch();
ps.executeBatch();

ps.setObject(1, new Double(45));
ps.setObject(1, 45.0);
ps.setObject(2, new Date(45)); // <-- this causes "oid of bind unknown, send Describe"
ps.addBatch();
ps.setNull(1, Types.SMALLINT);
Expand All @@ -642,7 +642,7 @@ public void testBatchWithAlternatingAndUnknownTypesN(int numPreliminaryInserts)

// This execution with (double, unknown) passes isPreparedForTypes check, and causes
// the failure
ps.setObject(1, new Double(47));
ps.setObject(1, 47.0);
ps.setObject(2, new Date(47));
ps.addBatch();
ps.executeBatch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void testStringToIntervalCoercion() throws SQLException {
PreparedStatement pstmt = conn.prepareStatement(
"SELECT v FROM testdate WHERE v < (?::timestamp with time zone + ? * ?::interval) ORDER BY v");
pstmt.setObject(1, makeDate(2010, 1, 1));
pstmt.setObject(2, Integer.valueOf(2));
pstmt.setObject(2, 2);
pstmt.setObject(3, "1 day");
ResultSet rs = pstmt.executeQuery();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ public void testBoolean(int prepareThreshold) throws SQLException {
pstmt.setObject(2, BigDecimal.ONE, Types.BOOLEAN);
pstmt.setObject(3, 0L, Types.BOOLEAN);
pstmt.setObject(4, 0x1, Types.BOOLEAN);
pstmt.setObject(5, new Float(0), Types.BOOLEAN);
pstmt.setObject(5, (float) 0, Types.BOOLEAN);
pstmt.setObject(5, 1.0d, Types.BOOLEAN);
pstmt.setObject(5, 0.0f, Types.BOOLEAN);
pstmt.setObject(6, Integer.valueOf("1"), Types.BOOLEAN);
Expand Down Expand Up @@ -859,11 +859,11 @@ public void testSetFloatInteger() throws SQLException {
pstmt.executeUpdate();
pstmt.close();

Integer maxInteger = new Integer(2147483647);
Integer minInteger = new Integer(-2147483648);
Integer maxInteger = 2147483647;
Integer minInteger = -2147483648;

Double maxFloat = new Double(2147483647);
Double minFloat = new Double(-2147483648);
Double maxFloat = 2147483647.0;
Double minFloat = (double) -2147483648;

pstmt = con.prepareStatement("insert into float_tab values (?,?,?)");
pstmt.setObject(1, maxInteger, Types.FLOAT);
Expand Down Expand Up @@ -896,8 +896,8 @@ public void testSetFloatString() throws SQLException {

String maxStringFloat = "1.0E37";
String minStringFloat = "1.0E-37";
Double maxFloat = new Double(1.0E37);
Double minFloat = new Double(1.0E-37);
Double maxFloat = 1.0E37;
Double minFloat = 1.0E-37;

pstmt = con.prepareStatement("insert into float_tab values (?,?,?)");
pstmt.setObject(1, maxStringFloat, Types.FLOAT);
Expand Down Expand Up @@ -939,8 +939,8 @@ public void testSetFloatBigDecimal() throws SQLException {

BigDecimal maxBigDecimalFloat = new BigDecimal("1.0E37");
BigDecimal minBigDecimalFloat = new BigDecimal("1.0E-37");
Double maxFloat = new Double(1.0E37);
Double minFloat = new Double(1.0E-37);
Double maxFloat = 1.0E37;
Double minFloat = 1.0E-37;

pstmt = con.prepareStatement("insert into float_tab values (?,?,?)");
pstmt.setObject(1, maxBigDecimalFloat, Types.FLOAT);
Expand Down Expand Up @@ -971,10 +971,10 @@ public void testSetTinyIntFloat() throws SQLException {
pstmt.executeUpdate();
pstmt.close();

Integer maxInt = new Integer(127);
Integer minInt = new Integer(-127);
Float maxIntFloat = new Float(127);
Float minIntFloat = new Float(-127);
Integer maxInt = 127;
Integer minInt = -127;
Float maxIntFloat = 127F;
Float minIntFloat = (float) -127;

pstmt = con.prepareStatement("insert into tiny_int values (?,?,?)");
pstmt.setObject(1, maxIntFloat, Types.TINYINT);
Expand Down Expand Up @@ -1027,10 +1027,10 @@ public void testSetSmallIntFloat() throws SQLException {
pstmt.executeUpdate();
pstmt.close();

Integer maxInt = new Integer(32767);
Integer minInt = new Integer(-32768);
Float maxIntFloat = new Float(32767);
Float minIntFloat = new Float(-32768);
Integer maxInt = 32767;
Integer minInt = -32768;
Float maxIntFloat = 32767F;
Float minIntFloat = (float) -32768;

pstmt = con.prepareStatement("insert into small_int values (?,?,?)");
pstmt.setObject(1, maxIntFloat, Types.SMALLINT);
Expand Down Expand Up @@ -1060,10 +1060,10 @@ public void testSetIntFloat() throws SQLException {
pstmt.executeUpdate();
pstmt.close();

Integer maxInt = new Integer(1000);
Integer minInt = new Integer(-1000);
Float maxIntFloat = new Float(1000);
Float minIntFloat = new Float(-1000);
Integer maxInt = 1000;
Integer minInt = -1000;
Float maxIntFloat = 1000F;
Float minIntFloat = (float) -1000;

pstmt = con.prepareStatement("insert into int_tab values (?,?,?)");
pstmt.setObject(1, maxIntFloat, Types.INTEGER);
Expand Down Expand Up @@ -1094,8 +1094,8 @@ public void testSetBooleanDouble() throws SQLException {
pstmt.executeUpdate();
pstmt.close();

Double dBooleanTrue = new Double(1);
Double dBooleanFalse = new Double(0);
Double dBooleanTrue = 1.0;
Double dBooleanFalse = (double) 0;

pstmt = con.prepareStatement("insert into double_tab values (?,?,?)");
pstmt.setObject(1, Boolean.TRUE, Types.DOUBLE);
Expand Down Expand Up @@ -1349,7 +1349,7 @@ public void testUnknownSetObject() throws SQLException {
@Test
public void testSetObjectCharacter() throws SQLException {
PreparedStatement ps = con.prepareStatement("INSERT INTO texttable(te) VALUES (?)");
ps.setObject(1, new Character('z'));
ps.setObject(1, 'z');
ps.executeUpdate();
ps.close();
}
Expand All @@ -1362,7 +1362,7 @@ public void testSetObjectCharacter() throws SQLException {
@Test
public void testStatementDescribe() throws SQLException {
PreparedStatement pstmt = con.prepareStatement("SELECT ?::int");
pstmt.setObject(1, new Integer(2), Types.OTHER);
pstmt.setObject(1, 2, Types.OTHER);
for (int i = 0; i < 10; i++) {
ResultSet rs = pstmt.executeQuery();
assertTrue(rs.next());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,10 @@ public void testUpdateReal() throws Throwable {
cstmt.close();
ResultSet rs = con.createStatement().executeQuery("select * from real_tab");
assertTrue(rs.next());
Float oVal = new Float(intValues[0]);
Float oVal = (float) intValues[0];
Float rVal = new Float(rs.getObject(1).toString());
assertTrue(oVal.equals(rVal));
oVal = new Float(intValues[1]);
oVal = (float) intValues[1];
rVal = new Float(rs.getObject(2).toString());
assertTrue(oVal.equals(rVal));
rs.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void testPreparedBoolean() throws SQLException {
public void testPreparedByte() throws SQLException {
PreparedStatement pstmt = conn.prepareStatement("SELECT ?,?");
pstmt.setByte(1, (byte) 1);
pstmt.setObject(2, new Byte((byte) 2));
pstmt.setObject(2, (byte) 2);
ResultSet rs = pstmt.executeQuery();
assertTrue(rs.next());
assertEquals((byte) 1, rs.getByte(1));
Expand Down

0 comments on commit 61aee4d

Please sign in to comment.