This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 09ed5e5c4e GH-44011: [Java] Consider warnings as errors for C Module
(#44012)
09ed5e5c4e is described below
commit 09ed5e5c4ed9e7fd1619bf3bf3a5c88be4540a40
Author: Vibhatha Lakmal Abeykoon <[email protected]>
AuthorDate: Tue Sep 10 05:56:18 2024 +0530
GH-44011: [Java] Consider warnings as errors for C Module (#44012)
### Rationale for this change
This PR configs the build such that warnings are considered as errors in
the C module. And corresponding code changes have also been made.
### What changes are included in this PR?
Adding flags to consider warnings as errors in javac and fixing the
corresponding errors.
### Are these changes tested?
Tested by existing test cases.
### Are there any user-facing changes?
N/A
* GitHub Issue: #44011
Authored-by: Vibhatha Lakmal Abeykoon <[email protected]>
Signed-off-by: David Li <[email protected]>
---
java/c/pom.xml | 11 +++++++++++
java/c/src/main/java/org/apache/arrow/c/ArrayExporter.java | 2 +-
.../main/java/org/apache/arrow/c/BufferImportTypeVisitor.java | 2 +-
java/c/src/test/java/org/apache/arrow/c/DictionaryTest.java | 8 ++++----
java/c/src/test/java/org/apache/arrow/c/RoundtripTest.java | 8 --------
5 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/java/c/pom.xml b/java/c/pom.xml
index 5296235404..fe57bd2ea0 100644
--- a/java/c/pom.xml
+++ b/java/c/pom.xml
@@ -91,5 +91,16 @@ under the License.
</includes>
</resource>
</resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration combine.children="append">
+ <compilerArgs>
+ <arg>-Werror</arg>
+ </compilerArgs>
+ </configuration>
+ </plugin>
+ </plugins>
</build>
</project>
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 820a152274..0c6b5de448 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 @@ final class ArrayExporter {
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 93fef6d7ca..e47d27bf09 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 @@ class BufferImportTypeVisitor implements
ArrowType.ArrowTypeVisitor<List<ArrowBu
private List<ArrowBuf> 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<ArrowBuf> 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 ce0e82586b..8cd4913f22 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 @@ public class DictionaryTest {
// 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 @@ public class DictionaryTest {
// 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 18b2e94add..d8286465e4 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 class RoundtripTest {
}
}
- 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