Skip to content

Commit 61aee4d

Browse files
committed
chore: run "Unnecessary boxing" inspection in IDEA
new Double(..), new Integer(..) have been deprecated for removal
1 parent ed866f0 commit 61aee4d

File tree

6 files changed

+33
-33
lines changed

6 files changed

+33
-33
lines changed

pgjdbc/src/test/java/org/postgresql/test/jdbc2/ArrayTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public void testSetPrimitiveArraysObjects() throws SQLException {
327327
Assert.assertEquals("fa\"b", strarr[1]);
328328

329329
try {
330-
arraySupport.createArrayOf("int4", Integer.valueOf(1));
330+
arraySupport.createArrayOf("int4", 1);
331331
fail("not an array");
332332
} catch (PSQLException e) {
333333

pgjdbc/src/test/java/org/postgresql/test/jdbc2/BatchExecuteTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,15 +619,15 @@ public void testBatchWithAlternatingAndUnknownTypesN(int numPreliminaryInserts)
619619
ps.executeBatch();
620620
}
621621

622-
ps.setObject(1, new Double(43));
622+
ps.setObject(1, 43.0);
623623
ps.setObject(2, new Date(43));
624624
ps.addBatch();
625625
ps.setNull(1, Types.SMALLINT);
626626
ps.setObject(2, new Date(44));
627627
ps.addBatch();
628628
ps.executeBatch();
629629

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

643643
// This execution with (double, unknown) passes isPreparedForTypes check, and causes
644644
// the failure
645-
ps.setObject(1, new Double(47));
645+
ps.setObject(1, 47.0);
646646
ps.setObject(2, new Date(47));
647647
ps.addBatch();
648648
ps.executeBatch();

pgjdbc/src/test/java/org/postgresql/test/jdbc2/IntervalTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void testStringToIntervalCoercion() throws SQLException {
7979
PreparedStatement pstmt = conn.prepareStatement(
8080
"SELECT v FROM testdate WHERE v < (?::timestamp with time zone + ? * ?::interval) ORDER BY v");
8181
pstmt.setObject(1, makeDate(2010, 1, 1));
82-
pstmt.setObject(2, Integer.valueOf(2));
82+
pstmt.setObject(2, 2);
8383
pstmt.setObject(3, "1 day");
8484
ResultSet rs = pstmt.executeQuery();
8585

pgjdbc/src/test/java/org/postgresql/test/jdbc2/PreparedStatementTest.java

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ public void testBoolean(int prepareThreshold) throws SQLException {
726726
pstmt.setObject(2, BigDecimal.ONE, Types.BOOLEAN);
727727
pstmt.setObject(3, 0L, Types.BOOLEAN);
728728
pstmt.setObject(4, 0x1, Types.BOOLEAN);
729-
pstmt.setObject(5, new Float(0), Types.BOOLEAN);
729+
pstmt.setObject(5, (float) 0, Types.BOOLEAN);
730730
pstmt.setObject(5, 1.0d, Types.BOOLEAN);
731731
pstmt.setObject(5, 0.0f, Types.BOOLEAN);
732732
pstmt.setObject(6, Integer.valueOf("1"), Types.BOOLEAN);
@@ -859,11 +859,11 @@ public void testSetFloatInteger() throws SQLException {
859859
pstmt.executeUpdate();
860860
pstmt.close();
861861

862-
Integer maxInteger = new Integer(2147483647);
863-
Integer minInteger = new Integer(-2147483648);
862+
Integer maxInteger = 2147483647;
863+
Integer minInteger = -2147483648;
864864

865-
Double maxFloat = new Double(2147483647);
866-
Double minFloat = new Double(-2147483648);
865+
Double maxFloat = 2147483647.0;
866+
Double minFloat = (double) -2147483648;
867867

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

897897
String maxStringFloat = "1.0E37";
898898
String minStringFloat = "1.0E-37";
899-
Double maxFloat = new Double(1.0E37);
900-
Double minFloat = new Double(1.0E-37);
899+
Double maxFloat = 1.0E37;
900+
Double minFloat = 1.0E-37;
901901

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

940940
BigDecimal maxBigDecimalFloat = new BigDecimal("1.0E37");
941941
BigDecimal minBigDecimalFloat = new BigDecimal("1.0E-37");
942-
Double maxFloat = new Double(1.0E37);
943-
Double minFloat = new Double(1.0E-37);
942+
Double maxFloat = 1.0E37;
943+
Double minFloat = 1.0E-37;
944944

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

974-
Integer maxInt = new Integer(127);
975-
Integer minInt = new Integer(-127);
976-
Float maxIntFloat = new Float(127);
977-
Float minIntFloat = new Float(-127);
974+
Integer maxInt = 127;
975+
Integer minInt = -127;
976+
Float maxIntFloat = 127F;
977+
Float minIntFloat = (float) -127;
978978

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

1030-
Integer maxInt = new Integer(32767);
1031-
Integer minInt = new Integer(-32768);
1032-
Float maxIntFloat = new Float(32767);
1033-
Float minIntFloat = new Float(-32768);
1030+
Integer maxInt = 32767;
1031+
Integer minInt = -32768;
1032+
Float maxIntFloat = 32767F;
1033+
Float minIntFloat = (float) -32768;
10341034

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

1063-
Integer maxInt = new Integer(1000);
1064-
Integer minInt = new Integer(-1000);
1065-
Float maxIntFloat = new Float(1000);
1066-
Float minIntFloat = new Float(-1000);
1063+
Integer maxInt = 1000;
1064+
Integer minInt = -1000;
1065+
Float maxIntFloat = 1000F;
1066+
Float minIntFloat = (float) -1000;
10671067

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

1097-
Double dBooleanTrue = new Double(1);
1098-
Double dBooleanFalse = new Double(0);
1097+
Double dBooleanTrue = 1.0;
1098+
Double dBooleanFalse = (double) 0;
10991099

11001100
pstmt = con.prepareStatement("insert into double_tab values (?,?,?)");
11011101
pstmt.setObject(1, Boolean.TRUE, Types.DOUBLE);
@@ -1349,7 +1349,7 @@ public void testUnknownSetObject() throws SQLException {
13491349
@Test
13501350
public void testSetObjectCharacter() throws SQLException {
13511351
PreparedStatement ps = con.prepareStatement("INSERT INTO texttable(te) VALUES (?)");
1352-
ps.setObject(1, new Character('z'));
1352+
ps.setObject(1, 'z');
13531353
ps.executeUpdate();
13541354
ps.close();
13551355
}
@@ -1362,7 +1362,7 @@ public void testSetObjectCharacter() throws SQLException {
13621362
@Test
13631363
public void testStatementDescribe() throws SQLException {
13641364
PreparedStatement pstmt = con.prepareStatement("SELECT ?::int");
1365-
pstmt.setObject(1, new Integer(2), Types.OTHER);
1365+
pstmt.setObject(1, 2, Types.OTHER);
13661366
for (int i = 0; i < 10; i++) {
13671367
ResultSet rs = pstmt.executeQuery();
13681368
assertTrue(rs.next());

pgjdbc/src/test/java/org/postgresql/test/jdbc3/Jdbc3CallableStatementTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,10 +591,10 @@ public void testUpdateReal() throws Throwable {
591591
cstmt.close();
592592
ResultSet rs = con.createStatement().executeQuery("select * from real_tab");
593593
assertTrue(rs.next());
594-
Float oVal = new Float(intValues[0]);
594+
Float oVal = (float) intValues[0];
595595
Float rVal = new Float(rs.getObject(1).toString());
596596
assertTrue(oVal.equals(rVal));
597-
oVal = new Float(intValues[1]);
597+
oVal = (float) intValues[1];
598598
rVal = new Float(rs.getObject(2).toString());
599599
assertTrue(oVal.equals(rVal));
600600
rs.close();

pgjdbc/src/test/java/org/postgresql/test/jdbc3/TypesTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void testPreparedBoolean() throws SQLException {
7070
public void testPreparedByte() throws SQLException {
7171
PreparedStatement pstmt = conn.prepareStatement("SELECT ?,?");
7272
pstmt.setByte(1, (byte) 1);
73-
pstmt.setObject(2, new Byte((byte) 2));
73+
pstmt.setObject(2, (byte) 2);
7474
ResultSet rs = pstmt.executeQuery();
7575
assertTrue(rs.next());
7676
assertEquals((byte) 1, rs.getByte(1));

0 commit comments

Comments
 (0)