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:
{code}
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());
init();
}
{code}
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:
{code}
private final static RuntimeDelegate delegate =
RuntimeDelegate
.getInstance();
private static final HeaderDelegate<EntityTag> ENTITY_TAG_HEADER_DELEGATE =
delegate
.createHeaderDelegate(EntityTag.class);
{code}
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:
{code}
ifMatchHeader.addETag(ENTITY_TAG_HEADER_DELEGATE.fromString(token));
{code}
I've modified a little bit the code of fromString() to look like that and works
perfectly:
{code}
HeaderDelegate<EntityTag> ENTITY_TAG_HEADER_DELEGATE =
RuntimeDelegate.getInstance().createHeaderDelegate(EntityTag.class);
ifMatchHeader.addETag(ENTITY_TAG_HEADER_DELEGATE.fromString(token));
{code}
Fixing those static fields in EntityTagMatchHeaderDelegate class only, makes
DummyRuntimeDelegate obsolete.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)