From 01d9cc5fb65c7f6778e1e25c2c4af45bde5b57cd Mon Sep 17 00:00:00 2001 From: Andrew Kabas Date: Thu, 5 Dec 2024 10:21:56 -0500 Subject: [PATCH] Fix checkstyle errors --- .../main/java/com/spotify/dbeam/avro/JdbcAvroRecord.java | 5 +---- .../com/spotify/dbeam/avro/JdbcAvroRecordConverter.java | 5 +++-- .../main/java/com/spotify/dbeam/avro/JdbcAvroSchema.java | 4 ++-- dbeam-core/src/test/java/com/spotify/dbeam/Coffee.java | 9 ++++++--- .../java/com/spotify/dbeam/avro/JdbcAvroRecordTest.java | 4 ++-- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/dbeam-core/src/main/java/com/spotify/dbeam/avro/JdbcAvroRecord.java b/dbeam-core/src/main/java/com/spotify/dbeam/avro/JdbcAvroRecord.java index 11c4278d..4d7bafe3 100644 --- a/dbeam-core/src/main/java/com/spotify/dbeam/avro/JdbcAvroRecord.java +++ b/dbeam-core/src/main/java/com/spotify/dbeam/avro/JdbcAvroRecord.java @@ -113,10 +113,7 @@ static SqlFunction computeMapping( return resultSet -> nullableBytes(resultSet.getBytes(column)); } case ARRAY: - return resultSet -> { -// java.sql.Array arr = resultSet.getArray(column); - return resultSet.getArray(column); - }; + return resultSet -> resultSet.getArray(column); case BINARY: case VARBINARY: case LONGVARBINARY: diff --git a/dbeam-core/src/main/java/com/spotify/dbeam/avro/JdbcAvroRecordConverter.java b/dbeam-core/src/main/java/com/spotify/dbeam/avro/JdbcAvroRecordConverter.java index 9456e094..cc74d66b 100644 --- a/dbeam-core/src/main/java/com/spotify/dbeam/avro/JdbcAvroRecordConverter.java +++ b/dbeam-core/src/main/java/com/spotify/dbeam/avro/JdbcAvroRecordConverter.java @@ -104,7 +104,8 @@ public ByteBuffer convertResultSetIntoAvroBytes() throws SQLException, IOExcepti return ByteBuffer.wrap(out.getBufffer(), 0, out.size()); } - private void writeValue(Object value, BinaryEncoder binaryEncoder) throws SQLException, IOException { + private void writeValue(Object value, BinaryEncoder binaryEncoder) + throws SQLException, IOException { if (value instanceof String) { binaryEncoder.writeString((String) value); } else if (value instanceof Long) { @@ -121,7 +122,7 @@ private void writeValue(Object value, BinaryEncoder binaryEncoder) throws SQLExc binaryEncoder.writeFloat((Float) value); } else if (value instanceof java.sql.Array) { binaryEncoder.writeArrayStart(); - Object[] array = (Object[])((java.sql.Array)value).getArray(); + Object[] array = (Object[]) ((java.sql.Array) value).getArray(); binaryEncoder.setItemCount(array.length); for (Object arrayItem : array) { binaryEncoder.startItem(); diff --git a/dbeam-core/src/main/java/com/spotify/dbeam/avro/JdbcAvroSchema.java b/dbeam-core/src/main/java/com/spotify/dbeam/avro/JdbcAvroSchema.java index 78966c29..1e846b6a 100644 --- a/dbeam-core/src/main/java/com/spotify/dbeam/avro/JdbcAvroSchema.java +++ b/dbeam-core/src/main/java/com/spotify/dbeam/avro/JdbcAvroSchema.java @@ -162,8 +162,8 @@ private static SchemaBuilder.FieldAssembler createAvroFields( SchemaBuilder.UnionAccumulator>> fieldSchemaBuilder = field.type().unionOf().nullBuilder().endNull().and(); - Integer arrayItemType = resultSet.isFirst() && columnType == ARRAY ? - resultSet.getArray(i).getBaseType() : null; + Integer arrayItemType = resultSet.isFirst() && columnType == ARRAY + ? resultSet.getArray(i).getBaseType() : null; final SchemaBuilder.UnionAccumulator> schemaFieldAssembler = setAvroColumnType( diff --git a/dbeam-core/src/test/java/com/spotify/dbeam/Coffee.java b/dbeam-core/src/test/java/com/spotify/dbeam/Coffee.java index 052f3378..af181643 100644 --- a/dbeam-core/src/test/java/com/spotify/dbeam/Coffee.java +++ b/dbeam-core/src/test/java/com/spotify/dbeam/Coffee.java @@ -110,7 +110,7 @@ public String insertStatement() { updated().orElse(null), uid(), rownum(), - String.join(",", intArr().stream().map(x -> (CharSequence)x.toString())::iterator), + String.join(",", intArr().stream().map(x -> (CharSequence) x.toString())::iterator), String.join("','", textArr())); } @@ -156,7 +156,9 @@ public static String ddl() { add("rock"); add("scissors"); add("paper"); - }}); + }} + ); + public static Coffee COFFEE2 = create( "colombian caffee", @@ -180,5 +182,6 @@ public static String ddl() { add("scissors"); add("paper"); add("rock"); - }}); + }} + ); } diff --git a/dbeam-core/src/test/java/com/spotify/dbeam/avro/JdbcAvroRecordTest.java b/dbeam-core/src/test/java/com/spotify/dbeam/avro/JdbcAvroRecordTest.java index 83c1752f..0ea2b6f3 100644 --- a/dbeam-core/src/test/java/com/spotify/dbeam/avro/JdbcAvroRecordTest.java +++ b/dbeam-core/src/test/java/com/spotify/dbeam/avro/JdbcAvroRecordTest.java @@ -207,7 +207,7 @@ public void shouldEncodeResultSetToValidAvro() Assert.assertEquals(14, record.getSchema().getFields().size()); Assert.assertEquals(schema, record.getSchema()); List actualTxtArray = - ((GenericData.Array)record.get(13)).stream().map(x -> x.toString()).collect( + ((GenericData.Array) record.get(13)).stream().map(x -> x.toString()).collect( Collectors.toList()); final Coffee actual = Coffee.create( @@ -223,7 +223,7 @@ public void shouldEncodeResultSetToValidAvro() Optional.ofNullable((Long) record.get(9)).map(Timestamp::new), TestHelper.byteBufferToUuid((ByteBuffer) record.get(10)), (Long) record.get(11), - new ArrayList<>((GenericData.Array)record.get(12)), + new ArrayList<>((GenericData.Array) record.get(12)), actualTxtArray); Assert.assertEquals(Coffee.COFFEE1, actual); }