pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] rdhabalia commented on a change in pull request #901: Introduce configuration converter
Date Thu, 01 Jan 1970 00:00:00 GMT
rdhabalia commented on a change in pull request #901: Introduce configuration converter
URL: https://github.com/apache/incubator-pulsar/pull/901#discussion_r151037495
 
 

 ##########
 File path: pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PulsarConfigurationLoader.java
 ##########
 @@ -127,4 +130,34 @@ public static boolean isComplete(Object obj) throws IllegalArgumentException,
Il
         return true;
     }
 
+    public static ServiceConfiguration convertFrom(PulsarConfiguration conf, boolean ignoreNonExistMember)
throws RuntimeException {
+        try {
+            final ServiceConfiguration convertedConf = ServiceConfiguration.class.newInstance();
+            Field[] confFields = conf.getClass().getDeclaredFields();
+            Arrays.stream(confFields).forEach(confField -> {
+                try {
+                    Field convertedConfField = ServiceConfiguration.class.getDeclaredField(confField.getName());
+                    confField.setAccessible(true);
+                    convertedConfField.setAccessible(true);
+                    convertedConfField.set(convertedConf, confField.get(conf));
+                } catch (NoSuchFieldException e) {
+                    if (!ignoreNonExistMember) {
+                        throw new RuntimeException("Exception caused while converting configuration:
" + e.getMessage());
 
 Review comment:
   should we throw specific RuntimeException such as `IllegalArgumentException` in case of
this validation? and also should we add comment about exception in method's java-doc section?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message