darkma773r commented on code in PR #186:
URL: 
https://github.com/apache/commons-configuration/pull/186#discussion_r897508540


##########
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 {

Review Comment:
   Good point. I suppose the scenario might be like this:
   - A user has both mailapi version on the classpath.
   - They call `convert` passing in the javax InternetAddress class. 
   - The converter sees that some type of InternetAddress has been requested 
and attempts to load the jakarta version, which is found.
   - A new jakarta InternetAddress is returned, which causes a class cast 
exception when being assigned to the javax InternetAddress variable.
   
   I've provided a fix for this in #188, where we only attempt to load and cast 
to the actual type given. Let me know what you think.



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