Skip to content

Commit c10028b

Browse files
authored
Fix UnusedVariable warnings across codebase (#37770)
supress warnings in tests
1 parent 7b06555 commit c10028b

File tree

70 files changed

+156
-157
lines changed

Some content is hidden

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

70 files changed

+156
-157
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,6 @@ class BeamModulePlugin implements Plugin<Project> {
15671567
"NullableTypeParameter",
15681568
"NullableWildcard",
15691569
"SuperCallToObjectMethod",
1570-
"UnusedVariable",
15711570
// intended suppressions emerged in newer protobuf versions
15721571
// For backward compatibility. Public method checked in before this check impl
15731572
// Possible use in interface subclasses

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
@@ -305,7 +305,8 @@ public void process(ProcessContext c, RestrictionTracker<SomeRestriction, Void>
305305
}
306306

307307
@GetInitialRestriction
308-
public SomeRestriction getInitialRestriction(@Element Integer elem) {
308+
public SomeRestriction getInitialRestriction(
309+
@SuppressWarnings("unused") @Element Integer elem) {
309310
return new SomeRestriction();
310311
}
311312
}
@@ -364,7 +365,7 @@ public void process(
364365
}
365366

366367
@GetInitialRestriction
367-
public OffsetRange getInitialRestriction(@Element Instant elem) {
368+
public OffsetRange getInitialRestriction(@SuppressWarnings("unused") @Element Instant elem) {
368369
throw new IllegalStateException("Expected to be supplied explicitly in this test");
369370
}
370371

@@ -446,7 +447,8 @@ public ProcessContinuation process(
446447
}
447448

448449
@GetInitialRestriction
449-
public SomeRestriction getInitialRestriction(@Element Integer elem) {
450+
public SomeRestriction getInitialRestriction(
451+
@SuppressWarnings("unused") @Element Integer elem) {
450452
return new SomeRestriction();
451453
}
452454
}
@@ -509,7 +511,7 @@ public ProcessContinuation process(
509511
}
510512

511513
@GetInitialRestriction
512-
public OffsetRange getInitialRestriction(@Element Integer elem) {
514+
public OffsetRange getInitialRestriction(@SuppressWarnings("unused") @Element Integer elem) {
513515
throw new UnsupportedOperationException("Expected to be supplied explicitly in this test");
514516
}
515517
}
@@ -630,12 +632,15 @@ private enum State {
630632
private State state = State.BEFORE_SETUP;
631633

632634
@ProcessElement
633-
public void process(ProcessContext c, RestrictionTracker<SomeRestriction, Void> tracker) {
635+
public void process(
636+
@SuppressWarnings("unused") ProcessContext c,
637+
@SuppressWarnings("unused") RestrictionTracker<SomeRestriction, Void> tracker) {
634638
assertEquals(State.INSIDE_BUNDLE, state);
635639
}
636640

637641
@GetInitialRestriction
638-
public SomeRestriction getInitialRestriction(@Element Integer element) {
642+
public SomeRestriction getInitialRestriction(
643+
@SuppressWarnings("unused") @Element Integer element) {
639644
return new SomeRestriction();
640645
}
641646

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/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(

runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/ExecutableStageDoFnOperator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,12 +1306,12 @@ private static void initializeUserState(
13061306

13071307
private static class NoOpDoFn<InputT, OutputT> extends DoFn<InputT, OutputT> {
13081308
@ProcessElement
1309-
public void doNothing(ProcessContext context) {}
1309+
public void doNothing(@SuppressWarnings("unused") ProcessContext context) {}
13101310
}
13111311

13121312
private static class StableNoOpDoFn<InputT, OutputT> extends DoFn<InputT, OutputT> {
13131313
@RequiresStableInput
13141314
@ProcessElement
1315-
public void doNothing(ProcessContext context) {}
1315+
public void doNothing(@SuppressWarnings("unused") ProcessContext context) {}
13161316
}
13171317
}

0 commit comments

Comments
 (0)