[jira] [Created] (WINK-426) wink-osgi is broken

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[jira] [Created] (WINK-426) wink-osgi is broken

JIRA jira@apache.org
Valentin Valchev created WINK-426:

             Summary: wink-osgi is broken
                 Key: WINK-426
                 URL: https://issues.apache.org/jira/browse/WINK-426
             Project: Wink
          Issue Type: Bug
          Components: OSGi
            Reporter: Valentin Valchev

I've been looking at WinkRequestProcessor code for a bug that I've experienced. There is a very strange method inside:
        protected void activate(ComponentContext context) {
                // hint from https://amdatu.atlassian.net/wiki/display/AMDATU/OSGiification
                // dummy RuntimeDelegate
                RuntimeDelegate.setInstance(new DummyRuntimeDelegate());
                RuntimeDelegate.setInstance(new RuntimeDelegateImpl());

Since I've got some NPEs when doing requests, I've been particularly interested in DummyRuntimeDelegate, which return only nulls.

Removing the class didn't helped at all. It actually prevented the bundle from being initialized.

Anyway, the problem seemed to be org.apache.wink.common.internal.providers.header.EntityTagMatchHeaderDelegate. It has the following code:
    private final static RuntimeDelegate           delegate                   =
    private static final HeaderDelegate<EntityTag> ENTITY_TAG_HEADER_DELEGATE =

So during the initialization of RuntimeDelegateImpl, this class is accessed and it's static fields are initialized. But during initialization RuntimeDelegate.getInstance() will return DummyDelegate, and then ENTITY_TAG_HEADER_DELEGATE will become null (Dummy delegate always returns nulls).

So in the fromString method, the line below will fail with NPE:

I've modified a little bit the code of fromString() to look like that and works perfectly:
HeaderDelegate<EntityTag> ENTITY_TAG_HEADER_DELEGATE = RuntimeDelegate.getInstance().createHeaderDelegate(EntityTag.class);

Fixing those static fields in EntityTagMatchHeaderDelegate class only, makes DummyRuntimeDelegate obsolete.

This message was sent by Atlassian JIRA