From aa4c52e66ceef5ca8cdc7c7ee0013b66b0420ccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20de=20Launois?= <> Date: Mon, 24 Feb 2025 21:47:39 +0100 Subject: [PATCH] Fix NPE --- pom.xml | 2 +- .../brotherql/backend/BrotherQLDeviceUsb.java | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index fc3508a..66d8f5c 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.delaunois brotherql - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT jar diff --git a/src/main/java/org/delaunois/brotherql/backend/BrotherQLDeviceUsb.java b/src/main/java/org/delaunois/brotherql/backend/BrotherQLDeviceUsb.java index b61ba2b..1f5da76 100644 --- a/src/main/java/org/delaunois/brotherql/backend/BrotherQLDeviceUsb.java +++ b/src/main/java/org/delaunois/brotherql/backend/BrotherQLDeviceUsb.java @@ -86,12 +86,14 @@ public BrotherQLDeviceUsb(URI uri) { throw new LibUsbException(Rx.msg("libusb.initerror"), result); LibUsb.setOption(context, LibUsb.OPTION_LOG_LEVEL, LibUsb.LOG_LEVEL_INFO); - if (!"usb".equals(uri.getScheme())) { - throw new IllegalArgumentException("Only usb supported"); - } - - if (!"Brother".equals(uri.getHost())) { - throw new IllegalArgumentException("Only Brother printers supported"); + if (uri != null) { + if (!"usb".equals(uri.getScheme())) { + throw new IllegalArgumentException("Only usb supported"); + } + + if (!"Brother".equals(uri.getHost())) { + throw new IllegalArgumentException("Only Brother printers supported"); + } } }