You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2022/06/09 02:56:00 UTC

[GitHub] [commons-configuration] kinow commented on a diff in pull request #107: Bump mailapi from 1.6.6 to 2.0.1

kinow commented on code in PR #107:
URL: https://github.com/apache/commons-configuration/pull/107#discussion_r893025170


##########
src/main/java/org/apache/commons/configuration2/convert/PropertyConverter.java:
##########
@@ -607,12 +612,22 @@ static Object toInternetAddress(final Object value) throws ConversionException {
         if (value.getClass().getName().equals(INTERNET_ADDRESS_CLASSNAME)) {
             return value;
         }
+        if (value.getClass().getName().equals(INTERNET_ADDRESS_CLASSNAME_JAKARTA)) {
+            return value;
+        }
         if (!(value instanceof String)) {
             throw new ConversionException("The value " + value + " can't be converted to a InternetAddress");
         }
         try {
-            final Constructor<?> ctor = Class.forName(INTERNET_ADDRESS_CLASSNAME).getConstructor(String.class);
-            return ctor.newInstance(value);
+            try {
+                // javamail-2.0+, with jakarta.mail.* namespace.
+                final Constructor<?> ctor = Class.forName(INTERNET_ADDRESS_CLASSNAME_JAKARTA).getConstructor(String.class);
+                return ctor.newInstance(value);
+            } catch (ClassNotFoundException e) {
+                // maybe javamail-1.*? With javax.mail.* namespace.

Review Comment:
   None from me :+1: feel free to take over the PR if you'd like/have time :)



-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org