tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Quintin Beukes (JIRA)" <j...@apache.org>
Subject [jira] Created: (OPENEJB-1070) LocalInitialContextFactory can't be extended
Date Thu, 10 Sep 2009 13:24:57 GMT
LocalInitialContextFactory can't be extended
--------------------------------------------

                 Key: OPENEJB-1070
                 URL: https://issues.apache.org/jira/browse/OPENEJB-1070
             Project: OpenEJB
          Issue Type: Bug
    Affects Versions: 3.1.2
            Reporter: Quintin Beukes
            Priority: Trivial
             Fix For: 3.1.2


When extended org.apache.openejb.client.LocalInitialContextFactory you can't use it to create
a new InitialContext. This is due to the way it constructs the LocalInitialContext object
using reflection, ie.:
            Constructor constructor = localInitialContext.getConstructor(Hashtable.class,
this.getClass());

If you extend it this.getClass() returns the new classes identity, and there won't be such
a constructor unless you override getInitialContext(Hashtable) and do it yourself. In most
cases this is fine, though there might be cases where you override it for other purposes,
and in these cases it becomes a problem.

Also. Anyone who used it like this in previous versions who upgrade will receive NoSuchMethod
exceptions.

Since it's intended for this.getClass() to return a LocalInitialContextFactory always (since
that's the only constructor provided by LocalInitialContext), you might as well reference
the class object statically, like so:
            Constructor constructor = localInitialContext.getConstructor(Hashtable.class,
LocalInitialContextFactory.class);

I attached a patch for this.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message