KalleOlaviNiemitalo commented on code in PR #3333:
URL: https://github.com/apache/avro/pull/3333#discussion_r1989192736
##########
lang/java/avro/src/main/java/org/apache/avro/specific/SpecificDatumReader.java:
##########
@@ -37,43 +37,72 @@ public class SpecificDatumReader<T> extends
GenericDatumReader<T> {
public static final String[] SERIALIZABLE_PACKAGES;
static {
- SERIALIZABLE_PACKAGES =
System.getProperty("org.apache.avro.SERIALIZABLE_PACKAGES",
-
"java.lang,java.math,java.io,java.net,org.apache.avro.reflect").split(",");
+ String defaultPackages =
"java.lang,java.math,java.io,java.net,org.apache.avro.reflect";
+
+ String userDefinedPackages =
System.getProperty("org.apache.avro.SERIALIZABLE_PACKAGES", "");
+
+ // Combine the user-defined packages (if any) with the default packages.
+ String combined = userProp.isEmpty() ? defaultPackages : userProp + "," +
defaultPackages;
+
+ SERIALIZABLE_PACKAGES = Arrays.stream(combined.split(","))
+ .distinct()
+ .toArray(String[]::new);
}
private final List<String> trustedPackages = new ArrayList<>();
public SpecificDatumReader() {
this(null, null, SpecificData.get());
+ initializeTrustedPackages();
}
Review Comment:
Calling `initializeTrustedPackages()` here is not necessary because this
constructor calls another constructor of the same class `this(null, null,
SpecificData.get())` and that constructor will call
`initializeTrustedPackages()`. It should be called only after the `super`
constructor.
This PR makes similar unnecessary changes to other delegating constructors
too.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]