From 6d8b9f667ea0b4d57bc4f118d6b6ec8386e6083b Mon Sep 17 00:00:00 2001 From: jsetton Date: Mon, 23 Dec 2024 03:07:19 -0500 Subject: [PATCH] [pushbullet] Replace deprecated URL constructor Signed-off-by: jsetton --- .../internal/handler/PushbulletHandler.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/bundles/org.openhab.binding.pushbullet/src/main/java/org/openhab/binding/pushbullet/internal/handler/PushbulletHandler.java b/bundles/org.openhab.binding.pushbullet/src/main/java/org/openhab/binding/pushbullet/internal/handler/PushbulletHandler.java index cd45afc12a6e9..881ca60484110 100644 --- a/bundles/org.openhab.binding.pushbullet/src/main/java/org/openhab/binding/pushbullet/internal/handler/PushbulletHandler.java +++ b/bundles/org.openhab.binding.pushbullet/src/main/java/org/openhab/binding/pushbullet/internal/handler/PushbulletHandler.java @@ -15,8 +15,7 @@ import static org.openhab.binding.pushbullet.internal.PushbulletBindingConstants.*; import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; +import java.net.URI; import java.nio.file.Files; import java.nio.file.Path; import java.util.Collection; @@ -279,13 +278,9 @@ private boolean sendPush(PushRequest request) { if (content.startsWith("data:")) { return IMAGE_FILE_NAME; } - try { - Path fileName = Path.of(content.startsWith("http") ? new URL(content).getPath() : content).getFileName(); - if (fileName != null) { - return fileName.toString(); - } - } catch (MalformedURLException e) { - logger.debug("Malformed url content: {}", e.getMessage()); + Path fileName = Path.of(content.startsWith("http") ? URI.create(content).getPath() : content).getFileName(); + if (fileName != null) { + return fileName.toString(); } return null; }