1

使用 Apache Felix 更新捆绑包时,我得到了 ArrayStoreException。它出现在与更新的包不同的包中。受影响的捆绑包有一个服务侦听器,该侦听器对更新的捆绑包注册的新服务做出反应。侦听器执行一些以 ArrayStoreException 结尾的代码。这是堆栈跟踪:

ERROR: Bundle com.elsten.bliss.platform [47] EventDispatcher: Error during dispatch. (java.lang.ArrayStoreException: com.elsten.bliss.music.policy.tag.tagtype.TagTypePolicy)
java.lang.ArrayStoreException: com.elsten.bliss.music.policy.tag.tagtype.TagTypePolicy
        at com.elsten.bliss.main.Main.getPolicies(Main.java:473)
        at com.elsten.bliss.main.Main.<init>(Main.java:150)
        at com.elsten.bliss.main.Main.startup(Main.java:143)
        at com.elsten.bliss.main.Activator$VersionServiceTracker.addingService(Activator.java:58)
        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:980)
        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:906)
        at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:262)
        at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:234)
        at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:941)
        at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:932)
        at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:793)
        at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:543)
        at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4260)
        at org.apache.felix.framework.Felix.registerService(Felix.java:3275)
        at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:346)
        at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:352)
        at com.elsten.osgi.Activator.start(Activator.java:28)
        at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:641)
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:1977)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1895)
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:931)
        at org.apache.felix.bundlerepository.impl.ResolverImpl.deploy(ResolverImpl.java:647)
        at com.elsten.bliss.updater.OnlineUpdater$2.run(OnlineUpdater.java:100)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:679)

getPolicies 中的代码(这是一个静态方法)访问一个静态最终变量:

private static final MusicPolicy tagTypePolicy = new TagTypePolicy();
private static MusicPolicy[] policies;
private static MusicPolicy[] getPolicies(Version version) {

    if(policies==null) {
        final HttpClientConfiguration httpClientConfig = HttpClientConfigurations.userAgentAndAcceptGzip(version);
        policies = new MusicPolicy[] {
            tagTypePolicy
        };
    }
    return policies;
}

我的猜测是这与类加载有关;更新后 MusicPolicy 或 TagTypePolicy 类不匹配。我有点困惑为什么会这样;鉴于这些是私有静态变量,尽管我的代码可以做它喜欢的事情。我认为,只有当静态数据导出到其他包时,才会出现问题。

4

0 回答 0