[ 
https://issues.apache.org/jira/browse/SQOOP-1425?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jarek Jarcec Cecho updated SQOOP-1425:
--------------------------------------

    Attachment: SQOOP-1425.patch

Attaching patch that was built for branch {{SQOOP-1375}} and hence the 
pre-commit build will again fail and I can't upload it to review board.

Instead of finding a constructor that matches given arguments, I've rewritten 
the {{ClasUtils.instantiate}} method to iterate over all constructors and 
simply try to call them one by one to see which one will be accepted. This will 
address both concerns mentioned in the JIRA. As "normal" classes won't have an 
excessive number of constructors I don't see performance implications here.

There is one downside though that I'm not sure how to resolve at the moment. If 
given set of arguments can satisfy multiple constructors (due to inheritance 
for example) then this implementation won't guarantee which constructor will be 
called. And even worst, different JDK versions can call different constructor 
reflect API is not guaranteeing order across different JDK versions.

Considering that this is internal util class, I think that the downside is 
pretty contained and is not blocking acceptance of the patch. We should open a 
follow-up JIRA to eventually fix this one though.

> Sqoop2: Improve ClassUtils to enable use of primitive types and subclasses
> --------------------------------------------------------------------------
>
>                 Key: SQOOP-1425
>                 URL: https://issues.apache.org/jira/browse/SQOOP-1425
>             Project: Sqoop
>          Issue Type: Bug
>    Affects Versions: 1.99.3
>            Reporter: Jarek Jarcec Cecho
>            Assignee: Jarek Jarcec Cecho
>             Fix For: 1.99.4
>
>         Attachments: SQOOP-1425.patch
>
>
> Current implementation of {{ClassUtils.instantiate}} have quite unfortunate 
> limitations:
> * Won't work with primitive types
> * Won't work when you need to call the constructor with subclass



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to