Skip to content

Commit 3b472aa

Browse files
authored
[ErrorProne] Enable UnsafeReflectiveConstructionCast check (#37784)
1 parent b9a7585 commit 3b472aa

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,6 @@ class BeamModulePlugin implements Plugin<Project> {
15611561
"UnnecessaryMethodReference",
15621562
"UnnecessaryParentheses",
15631563
"UnrecognisedJavadocTag",
1564-
"UnsafeReflectiveConstructionCast",
15651564
// errorprone 3.2.0+ checks
15661565
"DirectInvocationOnMock",
15671566
"Finalize",

sdks/java/extensions/avro/src/test/java/org/apache/beam/sdk/extensions/avro/schemas/utils/AvroUtilsTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,17 @@ private Iterable<?> randomData(org.apache.avro.Schema schema, int maxLength) thr
9292
Iterable<?> data;
9393
if (VERSION_AVRO.equals("1.8.2")) {
9494
data =
95-
(Iterable<?>)
96-
Class.forName("org.apache.avro.RandomData")
97-
.getDeclaredConstructor(org.apache.avro.Schema.class, Integer.TYPE)
98-
.newInstance(schema, maxLength);
95+
Class.forName("org.apache.avro.RandomData")
96+
.asSubclass(Iterable.class)
97+
.getDeclaredConstructor(org.apache.avro.Schema.class, Integer.TYPE)
98+
.newInstance(schema, maxLength);
9999
} else {
100100
data =
101-
(Iterable<?>)
102-
Class.forName("org.apache.avro.util.RandomData")
103-
.getDeclaredConstructor(org.apache.avro.Schema.class, Integer.TYPE, Boolean.TYPE)
104-
// force Utf8 in random data to match with String type used in AvroUtils
105-
.newInstance(schema, maxLength, true);
101+
Class.forName("org.apache.avro.util.RandomData")
102+
.asSubclass(Iterable.class)
103+
.getDeclaredConstructor(org.apache.avro.Schema.class, Integer.TYPE, Boolean.TYPE)
104+
// force Utf8 in random data to match with String type used in AvroUtils
105+
.newInstance(schema, maxLength, true);
106106
}
107107
return data;
108108
}

0 commit comments

Comments
 (0)