shunping commented on code in PR #39940:
URL: https://github.com/apache/beam/pull/39940#discussion_r3926192354


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/util/Secret.java:
##########
@@ -35,6 +38,30 @@
  * should be able to return a valid byte array representing the secret.
  */
 public abstract class Secret implements Serializable {
+  private static final Logger LOG = LoggerFactory.getLogger(Secret.class);
+  private static final Map<String, SecretRegistrar.SecretFactory> 
SECRET_FACTORIES =
+      loadSecretFactories();
+
+  private static Map<String, SecretRegistrar.SecretFactory> 
loadSecretFactories() {
+    Map<String, SecretRegistrar.SecretFactory> factories = new HashMap<>();
+    for (SecretRegistrar registrar : 
ReflectHelpers.loadServicesOrdered(SecretRegistrar.class)) {
+      for (Map.Entry<String, SecretRegistrar.SecretFactory> entry :
+          registrar.getSecretFactories().entrySet()) {
+        String key = entry.getKey().toLowerCase();
+        if (factories.containsKey(key)) {
+          throw new IllegalStateException(
+              String.format(
+                  "Duplicate SecretRegistrar for secret manager name '%s': %s 
and %s",
+                  key,
+                  factories.get(key).getClass().getName(),

Review Comment:
   Added code to give warning message if duplicating classes are seen and use 
the first-seen class in the factory.



-- 
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]

Reply via email to