From 4e6bc0976e07dad5a75800036f41c8ed5a65d9f9 Mon Sep 17 00:00:00 2001 From: GiviMAD Date: Mon, 7 Feb 2022 18:53:14 +0100 Subject: [PATCH] [porcupineks] fix null pointer exception and file bundle extraction on Windows OS (#12234) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Miguel Álvarez Díez --- .../voice/porcupineks/internal/PorcupineKSService.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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); -- 2.47.3