Skip to content

Commit de7af29

Browse files
committed
[MINOR][BUILD] Fix build warnings and Java lint errors
## What changes were proposed in this pull request? Fix build warnings and Java lint errors. This just helps a bit in evaluating (new) warnings in another PR I have open. ## How was this patch tested? Existing tests Author: Sean Owen <[email protected]> Closes apache#19051 from srowen/JavaWarnings.
1 parent 574ef6c commit de7af29

File tree

11 files changed

+17
-18
lines changed

11 files changed

+17
-18
lines changed

common/kvstore/src/main/java/org/apache/spark/util/kvstore/InMemoryStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public int size() {
171171
public <T> InMemoryView<T> view(Class<T> type) {
172172
Preconditions.checkArgument(ti.type().equals(type), "Unexpected type: %s", type);
173173
Collection<T> all = (Collection<T>) data.values();
174-
return new InMemoryView(type, all, ti);
174+
return new InMemoryView<>(type, all, ti);
175175
}
176176

177177
}

common/kvstore/src/main/java/org/apache/spark/util/kvstore/KVStoreIterator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.apache.spark.util.kvstore;
1919

20+
import java.io.Closeable;
2021
import java.util.Iterator;
2122
import java.util.List;
2223

@@ -31,7 +32,7 @@
3132
* </p>
3233
*/
3334
@Private
34-
public interface KVStoreIterator<T> extends Iterator<T>, AutoCloseable {
35+
public interface KVStoreIterator<T> extends Iterator<T>, Closeable {
3536

3637
/**
3738
* Retrieve multiple elements from the store.

common/network-common/src/test/java/org/apache/spark/network/TransportRequestHandlerSuite.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void handleFetchRequestAndStreamRequest() throws Exception {
102102

103103
private class ExtendedChannelPromise extends DefaultChannelPromise {
104104

105-
private List<GenericFutureListener> listeners = new ArrayList<>();
105+
private List<GenericFutureListener<Future<Void>>> listeners = new ArrayList<>();
106106
private boolean success;
107107

108108
ExtendedChannelPromise(Channel channel) {
@@ -113,7 +113,10 @@ private class ExtendedChannelPromise extends DefaultChannelPromise {
113113
@Override
114114
public ChannelPromise addListener(
115115
GenericFutureListener<? extends Future<? super Void>> listener) {
116-
listeners.add(listener);
116+
@SuppressWarnings("unchecked")
117+
GenericFutureListener<Future<Void>> gfListener =
118+
(GenericFutureListener<Future<Void>>) listener;
119+
listeners.add(gfListener);
117120
return super.addListener(listener);
118121
}
119122

core/src/test/java/org/apache/spark/launcher/SparkLauncherSuite.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.util.HashMap;
2222
import java.util.Map;
2323

24-
import org.junit.Before;
2524
import org.junit.Test;
2625
import org.slf4j.Logger;
2726
import org.slf4j.LoggerFactory;

launcher/src/test/java/org/apache/spark/launcher/ChildProcAppHandleSuite.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.apache.spark.launcher;
1919

2020
import java.io.File;
21-
import java.io.IOException;
2221
import java.nio.file.Files;
2322
import java.nio.file.Path;
2423
import java.util.ArrayList;

mllib/src/test/scala/org/apache/spark/ml/tuning/CrossValidatorSuite.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,13 @@ class CrossValidatorSuite
187187
cv2.getEstimator match {
188188
case ova2: OneVsRest =>
189189
assert(ova.uid === ova2.uid)
190-
val classifier = ova2.getClassifier
191-
classifier match {
190+
ova2.getClassifier match {
192191
case lr: LogisticRegression =>
193192
assert(ova.getClassifier.asInstanceOf[LogisticRegression].getMaxIter
194193
=== lr.getMaxIter)
195-
case _ =>
194+
case other =>
196195
throw new AssertionError(s"Loaded CrossValidator expected estimator of type" +
197-
s" LogisticREgression but found ${classifier.getClass.getName}")
196+
s" LogisticRegression but found ${other.getClass.getName}")
198197
}
199198

200199
case other =>

mllib/src/test/scala/org/apache/spark/ml/tuning/TrainValidationSplitSuite.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,13 @@ class TrainValidationSplitSuite
173173
tvs2.getEstimator match {
174174
case ova2: OneVsRest =>
175175
assert(ova.uid === ova2.uid)
176-
val classifier = ova2.getClassifier
177-
classifier match {
176+
ova2.getClassifier match {
178177
case lr: LogisticRegression =>
179178
assert(ova.getClassifier.asInstanceOf[LogisticRegression].getMaxIter
180179
=== lr.getMaxIter)
181-
case _ =>
180+
case other =>
182181
throw new AssertionError(s"Loaded TrainValidationSplit expected estimator of type" +
183-
s" LogisticREgression but found ${classifier.getClass.getName}")
182+
s" LogisticRegression but found ${other.getClass.getName}")
184183
}
185184

186185
case other =>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2058,7 +2058,7 @@
20582058
<javacArg>${java.version}</javacArg>
20592059
<javacArg>-target</javacArg>
20602060
<javacArg>${java.version}</javacArg>
2061-
<javacArg>-Xlint:all,-serial,-path</javacArg>
2061+
<javacArg>-Xlint:all,-serial,-path,-try</javacArg>
20622062
</javacArgs>
20632063
</configuration>
20642064
</plugin>

sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/VectorizedColumnReader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ private void decodeDictionaryIds(
350350
* is guaranteed that num is smaller than the number of values left in the current page.
351351
*/
352352

353-
private void readBooleanBatch(int rowId, int num, WritableColumnVector column) throws IOException {
353+
private void readBooleanBatch(int rowId, int num, WritableColumnVector column)
354+
throws IOException {
354355
assert(column.dataType() == DataTypes.BooleanType);
355356
defColumn.readBooleans(
356357
num, column, rowId, maxDefLevel, (VectorizedValuesReader) dataColumn);

sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/AggregateHashMap.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import com.google.common.annotations.VisibleForTesting;
2323

24-
import org.apache.spark.memory.MemoryMode;
2524
import org.apache.spark.sql.types.StructType;
2625

2726
import static org.apache.spark.sql.types.DataTypes.LongType;

0 commit comments

Comments
 (0)