diff --git a/lang/java/avro/src/test/java/org/apache/avro/specific/TestSpecificRecordWithUnion.java b/lang/java/avro/src/test/java/org/apache/avro/specific/TestSpecificRecordWithUnion.java index 70f3e7ac90a..b1a1dbe59cb 100644 --- a/lang/java/avro/src/test/java/org/apache/avro/specific/TestSpecificRecordWithUnion.java +++ b/lang/java/avro/src/test/java/org/apache/avro/specific/TestSpecificRecordWithUnion.java @@ -55,10 +55,18 @@ void testNotSerializableClasses() throws IOException { byte[] recordBytes = serializeRecord( "{ \"org.apache.avro.specific.TestUnionRecord\": { \"amount\": { \"bytes\": \"\\u0000\" } } }", schema); + // Use a fresh SpecificData so class resolution is not served from + // SpecificData.get()'s cache (other tests in this class may have resolved + // TestUnionRecord already, and surefire 3.6.x JUnit Platform ordering can + // run them first). The test must exercise the security validator on lookup. + SpecificDatumReader reader = new SpecificDatumReader<>(schema, schema, new SpecificData()); + ClassSecurityPredicate originalValidator = ClassSecurityValidator.getGlobal(); try { ClassSecurityValidator.setGlobal(ClassSecurityValidator.builder().build()); - assertThrows(SecurityException.class, () -> deserializeRecord(schema, recordBytes)); + ByteArrayInputStream in = new ByteArrayInputStream(recordBytes); + Decoder decoder = DecoderFactory.get().binaryDecoder(in, null); + assertThrows(SecurityException.class, () -> reader.read(null, decoder)); } finally { ClassSecurityValidator.setGlobal(originalValidator); } diff --git a/pom.xml b/pom.xml index 6693fc4cdfd..6d9e8ff13ae 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,7 @@ 3.3.0 3.5.2 3.11.0 - 3.5.6 + 3.6.1 1723122283