From: GiviMAD Date: Mon, 7 Feb 2022 17:53:14 +0000 (+0100) Subject: [porcupineks] fix null pointer exception and file bundle extraction on Windows OS... X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=4e6bc0976e07dad5a75800036f41c8ed5a65d9f9;p=openhab-addons.git [porcupineks] fix null pointer exception and file bundle extraction on Windows OS (#12234) Signed-off-by: Miguel Álvarez Díez --- diff --git a/bundles/org.openhab.voice.porcupineks/src/main/java/org/openhab/voice/porcupineks/internal/PorcupineKSService.java b/bundles/org.openhab.voice.porcupineks/src/main/java/org/openhab/voice/porcupineks/internal/PorcupineKSService.java index 41f44f5c10..c5174bae88 100644 --- a/bundles/org.openhab.voice.porcupineks/src/main/java/org/openhab/voice/porcupineks/internal/PorcupineKSService.java +++ b/bundles/org.openhab.voice.porcupineks/src/main/java/org/openhab/voice/porcupineks/internal/PorcupineKSService.java @@ -120,8 +120,16 @@ public class PorcupineKSService implements KSService { File localFile = new File(EXTRACTION_FOLDER, relativePath.substring(relativePath.lastIndexOf(File.separator) + 1)); if (!localFile.exists()) { + if (File.separator.equals("\\")) { + // bundle requires unix path separator + logger.debug("use unix path separator"); + relativePath = relativePath.replace("\\", "/"); + } URL porcupineResource = bundleContext.getBundle().getEntry(relativePath); logger.debug("extracting binary {} from bundle to extraction folder", relativePath); + if (porcupineResource == null) { + throw new IOException("Missing bundle file: " + relativePath); + } extractFromBundle(porcupineResource, localFile); } else { logger.debug("binary {} already extracted", relativePath);