From ce8a33f266826a7ae4487076eff91c6f3726c751 Mon Sep 17 00:00:00 2001 From: Vibhatha Lakmal Abeykoon Date: Mon, 9 Sep 2024 11:30:05 +0530 Subject: [PATCH] fix: errorprone warnings to error fixes added --- java/c/pom.xml | 35 +++++++++++++++++++ .../org/apache/arrow/c/ArrayExporter.java | 2 +- .../arrow/c/BufferImportTypeVisitor.java | 2 +- .../org/apache/arrow/c/DictionaryTest.java | 8 ++--- .../org/apache/arrow/c/RoundtripTest.java | 8 ----- 5 files changed, 41 insertions(+), 14 deletions(-) diff --git a/java/c/pom.xml b/java/c/pom.xml index 52962354047b1..28c44284d3e4b 100644 --- a/java/c/pom.xml +++ b/java/c/pom.xml @@ -91,5 +91,40 @@ under the License. + + + org.apache.maven.plugins + maven-compiler-plugin + + true + ${minimalJavaBuildVersion} + ${minimalJavaBuildVersion} + UTF-8 + + -XDcompilePolicy=simple + -Xplugin:ErrorProne -XepAllErrorsAsWarnings + -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED + -Werror + + + + com.google.errorprone + error_prone_core + ${error_prone_core.version} + + + + + + diff --git a/java/c/src/main/java/org/apache/arrow/c/ArrayExporter.java b/java/c/src/main/java/org/apache/arrow/c/ArrayExporter.java index 820a1522749c6..0c6b5de4486bc 100644 --- a/java/c/src/main/java/org/apache/arrow/c/ArrayExporter.java +++ b/java/c/src/main/java/org/apache/arrow/c/ArrayExporter.java @@ -90,7 +90,7 @@ void export(ArrowArray array, FieldVector vector, DictionaryProvider dictionaryP data.buffers = new ArrayList<>(vector.getExportedCDataBufferCount()); data.buffers_ptrs = - allocator.buffer((long) (vector.getExportedCDataBufferCount()) * Long.BYTES); + allocator.buffer((long) vector.getExportedCDataBufferCount() * Long.BYTES); vector.exportCDataBuffers(data.buffers, data.buffers_ptrs, NULL); if (dictionaryEncoding != null) { diff --git a/java/c/src/main/java/org/apache/arrow/c/BufferImportTypeVisitor.java b/java/c/src/main/java/org/apache/arrow/c/BufferImportTypeVisitor.java index 93fef6d7ca801..e47d27bf091ee 100644 --- a/java/c/src/main/java/org/apache/arrow/c/BufferImportTypeVisitor.java +++ b/java/c/src/main/java/org/apache/arrow/c/BufferImportTypeVisitor.java @@ -232,7 +232,7 @@ public List visit(ArrowType.Utf8 type) { private List visitVariableWidthView(ArrowType type) { final int viewBufferIndex = 1; final int variadicSizeBufferIndex = this.buffers.length - 1; - final long numOfVariadicBuffers = this.buffers.length - 3; + final long numOfVariadicBuffers = this.buffers.length - 3L; final long variadicSizeBufferCapacity = numOfVariadicBuffers * Long.BYTES; List buffers = new ArrayList<>(); diff --git a/java/c/src/test/java/org/apache/arrow/c/DictionaryTest.java b/java/c/src/test/java/org/apache/arrow/c/DictionaryTest.java index ce0e82586b766..8cd4913f22dd2 100644 --- a/java/c/src/test/java/org/apache/arrow/c/DictionaryTest.java +++ b/java/c/src/test/java/org/apache/arrow/c/DictionaryTest.java @@ -247,8 +247,8 @@ private void createStructVector(StructVector vector) { // Write the values to child 1 child1.allocateNew(); - child1.set(0, "01234567890".getBytes()); - child1.set(1, "012345678901234567".getBytes()); + child1.set(0, "01234567890".getBytes(StandardCharsets.UTF_8)); + child1.set(1, "012345678901234567".getBytes(StandardCharsets.UTF_8)); vector.setIndexDefined(0); // Write the values to child 2 @@ -269,8 +269,8 @@ private void createStructVectorInline(StructVector vector) { // Write the values to child 1 child1.allocateNew(); - child1.set(0, "012345678".getBytes()); - child1.set(1, "01234".getBytes()); + child1.set(0, "012345678".getBytes(StandardCharsets.UTF_8)); + child1.set(1, "01234".getBytes(StandardCharsets.UTF_8)); vector.setIndexDefined(0); // Write the values to child 2 diff --git a/java/c/src/test/java/org/apache/arrow/c/RoundtripTest.java b/java/c/src/test/java/org/apache/arrow/c/RoundtripTest.java index 18b2e94adde47..d8286465e475f 100644 --- a/java/c/src/test/java/org/apache/arrow/c/RoundtripTest.java +++ b/java/c/src/test/java/org/apache/arrow/c/RoundtripTest.java @@ -528,14 +528,6 @@ public void testVarBinaryVector() { } } - private String generateString(String str, int repetition) { - StringBuilder aRepeated = new StringBuilder(); - for (int i = 0; i < repetition; i++) { - aRepeated.append(str); - } - return aRepeated.toString(); - } - @Test public void testViewVector() { // ViewVarCharVector with short strings