Skip to content

Commit 7850f4e

Browse files
committed
Fix UnusedVariable warnings across codebase
1 parent 3197d88 commit 7850f4e

67 files changed

Lines changed: 154 additions & 155 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,6 @@ class BeamModulePlugin implements Plugin<Project> {
15871587
"StringCharset",
15881588
"SuperCallToObjectMethod",
15891589
"UnnecessaryLongToIntConversion",
1590-
"UnusedVariable",
15911590
// intended suppressions emerged in newer protobuf versions
15921591
"AutoValueBoxedValues",
15931592
// For backward compatibility. Public method checked in before this check impl

runners/core-java/src/test/java/org/apache/beam/runners/core/OutputAndTimeBoundedSplittableProcessElementInvokerTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public ProcessContinuation process(
9090
}
9191

9292
@GetInitialRestriction
93-
public OffsetRange getInitialRestriction(@Element Void element) {
93+
public OffsetRange getInitialRestriction(@SuppressWarnings("unused") @Element Void element) {
9494
throw new UnsupportedOperationException("Should not be called in this test");
9595
}
9696
}
@@ -209,7 +209,8 @@ public void process(ProcessContext c, RestrictionTracker<OffsetRange, Long> trac
209209
}
210210

211211
@GetInitialRestriction
212-
public OffsetRange getInitialRestriction(@Element Void element) {
212+
public OffsetRange getInitialRestriction(
213+
@SuppressWarnings("unused") @Element Void element) {
213214
throw new UnsupportedOperationException("Should not be called in this test");
214215
}
215216
};
@@ -228,7 +229,8 @@ public void process(ProcessContext c, RestrictionTracker<OffsetRange, Long> trac
228229
}
229230

230231
@GetInitialRestriction
231-
public OffsetRange getInitialRestriction(@Element Void element) {
232+
public OffsetRange getInitialRestriction(
233+
@SuppressWarnings("unused") @Element Void element) {
232234
throw new UnsupportedOperationException("Should not be called in this test");
233235
}
234236
};

runners/core-java/src/test/java/org/apache/beam/runners/core/SimplePushbackSideInputDoFnRunnerTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,8 @@ private static class MyDoFn extends DoFn<KV<String, Integer>, Integer> {
536536
public final StateSpec<ValueState<Integer>> intState = StateSpecs.value(VarIntCoder.of());
537537

538538
@ProcessElement
539-
public void processElement(ProcessContext c, @StateId(stateId) ValueState<Integer> state) {
539+
public void processElement(
540+
@SuppressWarnings("unused") ProcessContext c, @StateId(stateId) ValueState<Integer> state) {
540541
Integer currentValue = MoreObjects.firstNonNull(state.read(), 0);
541542
state.write(currentValue + 1);
542543
}

runners/core-java/src/test/java/org/apache/beam/runners/core/SplittableParDoProcessFnTest.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ public void process(ProcessContext c, RestrictionTracker<SomeRestriction, Void>
287287
}
288288

289289
@GetInitialRestriction
290-
public SomeRestriction getInitialRestriction(@Element Integer elem) {
290+
public SomeRestriction getInitialRestriction(
291+
@SuppressWarnings("unused") @Element Integer elem) {
291292
return new SomeRestriction();
292293
}
293294
}
@@ -342,7 +343,7 @@ public void process(
342343
}
343344

344345
@GetInitialRestriction
345-
public OffsetRange getInitialRestriction(@Element Instant elem) {
346+
public OffsetRange getInitialRestriction(@SuppressWarnings("unused") @Element Instant elem) {
346347
throw new IllegalStateException("Expected to be supplied explicitly in this test");
347348
}
348349

@@ -402,7 +403,8 @@ public ProcessContinuation process(
402403
}
403404

404405
@GetInitialRestriction
405-
public SomeRestriction getInitialRestriction(@Element Integer elem) {
406+
public SomeRestriction getInitialRestriction(
407+
@SuppressWarnings("unused") @Element Integer elem) {
406408
return new SomeRestriction();
407409
}
408410
}
@@ -465,7 +467,7 @@ public ProcessContinuation process(
465467
}
466468

467469
@GetInitialRestriction
468-
public OffsetRange getInitialRestriction(@Element Integer elem) {
470+
public OffsetRange getInitialRestriction(@SuppressWarnings("unused") @Element Integer elem) {
469471
throw new UnsupportedOperationException("Expected to be supplied explicitly in this test");
470472
}
471473
}
@@ -586,12 +588,15 @@ private enum State {
586588
private State state = State.BEFORE_SETUP;
587589

588590
@ProcessElement
589-
public void process(ProcessContext c, RestrictionTracker<SomeRestriction, Void> tracker) {
591+
public void process(
592+
@SuppressWarnings("unused") ProcessContext c,
593+
@SuppressWarnings("unused") RestrictionTracker<SomeRestriction, Void> tracker) {
590594
assertEquals(State.INSIDE_BUNDLE, state);
591595
}
592596

593597
@GetInitialRestriction
594-
public SomeRestriction getInitialRestriction(@Element Integer element) {
598+
public SomeRestriction getInitialRestriction(
599+
@SuppressWarnings("unused") @Element Integer element) {
595600
return new SomeRestriction();
596601
}
597602

runners/direct-java/src/main/java/org/apache/beam/runners/direct/DirectMetrics.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ public ResultT extractLatestAttempted() {
142142
* @param bundle The bundle being committed.
143143
* @param finalCumulative The final cumulative value for the given bundle.
144144
*/
145-
public void commitLogical(final CommittedBundle<?> bundle, final UpdateT finalCumulative) {
145+
public void commitLogical(
146+
@SuppressWarnings("unused") final CommittedBundle<?> bundle,
147+
final UpdateT finalCumulative) {
146148
UpdateT current;
147149
do {
148150
current = finishedCommitted.get();

runners/direct-java/src/test/java/org/apache/beam/runners/direct/DoFnLifecycleManagerRemovingTransformEvaluatorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,6 @@ public void removesOnExceptionInFinishBundle() throws Exception {
144144

145145
private static class TestFn extends DoFn<Object, Object> {
146146
@ProcessElement
147-
public void processElement(ProcessContext c) throws Exception {}
147+
public void processElement(@SuppressWarnings("unused") ProcessContext c) throws Exception {}
148148
}
149149
}

runners/direct-java/src/test/java/org/apache/beam/runners/direct/DoFnLifecycleManagerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public void setup() {
219219
}
220220

221221
@ProcessElement
222-
public void processElement(ProcessContext c) throws Exception {}
222+
public void processElement(@SuppressWarnings("unused") ProcessContext c) throws Exception {}
223223

224224
@Teardown
225225
public void teardown() {

runners/direct-java/src/test/java/org/apache/beam/runners/direct/DoFnLifecycleManagersTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private ThrowsInCleanupFn(String message) {
111111
}
112112

113113
@ProcessElement
114-
public void processElement(ProcessContext c) throws Exception {}
114+
public void processElement(@SuppressWarnings("unused") ProcessContext c) throws Exception {}
115115

116116
@Teardown
117117
public void teardown() throws Exception {
@@ -165,6 +165,6 @@ public void describeTo(Description description) {
165165

166166
private static class EmptyFn extends DoFn<Object, Object> {
167167
@ProcessElement
168-
public void processElement(ProcessContext c) throws Exception {}
168+
public void processElement(@SuppressWarnings("unused") ProcessContext c) throws Exception {}
169169
}
170170
}

runners/direct-java/src/test/java/org/apache/beam/runners/direct/UnboundedReadEvaluatorFactoryTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,10 @@ private static class TestUnboundedSource<T> extends UnboundedSource<T, TestCheck
496496

497497
static int readerCreatedCount;
498498
static int readerClosedCount;
499+
500+
@SuppressWarnings("unused")
499501
static int readerAdvancedCount;
502+
500503
private final Coder<T> coder;
501504
private final List<T> elems;
502505
private boolean dedupes = false;

runners/flink/2.0/src/main/java/org/apache/beam/runners/flink/FlinkExecutionEnvironments.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import org.apache.flink.configuration.StateBackendOptions;
4848
import org.apache.flink.configuration.TaskManagerOptions;
4949
import org.apache.flink.runtime.jobgraph.SavepointRestoreSettings;
50-
import org.apache.flink.runtime.state.StateBackend;
5150
import org.apache.flink.runtime.util.EnvironmentInformation;
5251
import org.apache.flink.streaming.api.CheckpointingMode;
5352
import org.apache.flink.streaming.api.environment.LocalStreamEnvironment;
@@ -390,7 +389,6 @@ private static void configureCheckpointing(
390389
}
391390

392391
private static void configureStateBackend(FlinkPipelineOptions options, Configuration config) {
393-
final StateBackend stateBackend;
394392
if (options.getStateBackend() != null) {
395393
final String storagePath = options.getStateBackendStoragePath();
396394
Preconditions.checkArgument(

0 commit comments

Comments
 (0)