calimero-project / calimero-core

Core library for KNX network access and management
Other
128 stars 65 forks source link

Calimero does not check for bundleresource protocol (equinox/osgi) #47

Closed MichaelGottschlich closed 7 years ago

MichaelGottschlich commented 7 years ago

Hallo,

i've had add to current Calimero core snapshot (2.4-SNAPSHOT) to openhab knx binding and be can an excetion:

java.nio.file.ProviderNotFoundException: Provider "bundleresource" not found
        at java.nio.file.FileSystems.newFileSystem(Unknown Source) ~[na:1.8.0_131]
        at java.nio.file.FileSystems.newFileSystem(Unknown Source) ~[na:1.8.0_131]
        at tuwien.auto.calimero.dptxlator.TranslatorTypes.loadTranslators(TranslatorTypes.java:369) ~[calimero-core-2.4-SNAPSHOT.jar:na]
        at tuwien.auto.calimero.dptxlator.TranslatorTypes.<clinit>(TranslatorTypes.java:347) ~[calimero-core-2.4-SNAPSHOT.jar:na]
        at org.openhab.binding.knx.internal.dpt.KNXCoreTypeMapper.toType(KNXCoreTypeMapper.java:326) [bundlefile:na]
        at org.openhab.binding.knx.internal.bus.KNXBinding.getType(KNXBinding.java:455) [bundlefile:na]
        at org.openhab.binding.knx.internal.bus.KNXBinding.readFromKNX(KNXBinding.java:225) [bundlefile:na]
        at org.openhab.binding.knx.internal.bus.KNXBinding.groupWrite(KNXBinding.java:186) [bundlefile:na]
        at tuwien.auto.calimero.process.ProcessCommunicatorImpl$NLListener.lambda$fireGroupReadWrite$2(ProcessCommunicatorImpl.java:128) [calimero-core-2.4-SNAPSHOT.jar:na]
        at tuwien.auto.calimero.internal.EventListeners.fire(EventListeners.java:129) ~[calimero-core-2.4-SNAPSHOT.jar:na]
        at tuwien.auto.calimero.process.ProcessCommunicatorImpl$NLListener.fireGroupReadWrite(ProcessCommunicatorImpl.java:129) [calimero-core-2.4-SNAPSHOT.jar:na]
        at tuwien.auto.calimero.process.ProcessCommunicatorImpl$NLListener.indication(ProcessCommunicatorImpl.java:111) [calimero-core-2.4-SNAPSHOT.jar:na]
        at tuwien.auto.calimero.link.AbstractLink$LinkNotifier.lambda$frameReceived$0(AbstractLink.java:144) ~[calimero-core-2.4-SNAPSHOT.jar:na]
        at tuwien.auto.calimero.internal.EventListeners.fire(EventListeners.java:129) ~[calimero-core-2.4-SNAPSHOT.jar:na]
        at tuwien.auto.calimero.link.EventNotifier.fire(EventNotifier.java:165) ~[calimero-core-2.4-SNAPSHOT.jar:na]
        at tuwien.auto.calimero.link.EventNotifier.run(EventNotifier.java:102) ~[calimero-core-2.4-SNAPSHOT.jar:na]

To fix the exception, modify the TranslatorTypes class. Pathset:

--- src/tuwien/auto/calimero/dptxlator/TranslatorTypes.java (revision e5481989b6ef199a128e5e19681d05dc311625fc)
+++ src/tuwien/auto/calimero/dptxlator/TranslatorTypes.java (revision )
@@ -368,7 +368,8 @@
                    loadTranslators(inPackage, fs.provider().getPath(uri));
                }
                catch (final Exception ex) {
-                   if (!"bundle".equals(uri.getScheme()))
+
+                   if (!"bundle".equals(uri.getScheme()) && ! "bundleresource".equals(uri.getScheme()))
                        throw ex;

                    DPTXlator.logger.info("using osgi bundle wiring for {}", uri);
calimero-project commented 7 years ago

Thx for the patch!