From 7f05c76563e73a6e825628a7160708b2003ed131 Mon Sep 17 00:00:00 2001 From: Per Cederberg Date: Sat, 9 Dec 2023 14:17:37 +0100 Subject: [PATCH] core: Removed unused exceptions --- src/java/org/rapidcontext/core/data/Binary.java | 3 +-- .../org/rapidcontext/core/security/SecurityContext.java | 3 +-- src/java/org/rapidcontext/util/BinaryUtil.java | 9 ++------- src/java/org/rapidcontext/util/ClasspathUtil.java | 1 - 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/java/org/rapidcontext/core/data/Binary.java b/src/java/org/rapidcontext/core/data/Binary.java index f651bbcc..0fc920a7 100644 --- a/src/java/org/rapidcontext/core/data/Binary.java +++ b/src/java/org/rapidcontext/core/data/Binary.java @@ -19,7 +19,6 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; import java.security.NoSuchAlgorithmException; @@ -231,7 +230,7 @@ public String mimeType() { public String sha256() { try { return BinaryUtil.hashSHA256(data); - } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { + } catch (NoSuchAlgorithmException e) { return null; } } diff --git a/src/java/org/rapidcontext/core/security/SecurityContext.java b/src/java/org/rapidcontext/core/security/SecurityContext.java index 2afca9fc..8af57e39 100644 --- a/src/java/org/rapidcontext/core/security/SecurityContext.java +++ b/src/java/org/rapidcontext/core/security/SecurityContext.java @@ -14,7 +14,6 @@ package org.rapidcontext.core.security; -import java.io.UnsupportedEncodingException; import java.security.NoSuchAlgorithmException; import java.util.logging.Level; import java.util.logging.Logger; @@ -292,7 +291,7 @@ public static User authHash(String id, String suffix, String hash) ", expected: " + test + ", received: " + hash); throw new SecurityException(msg); } - } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { + } catch (NoSuchAlgorithmException e) { String msg = "invalid environment, MD5 not supported"; LOG.log(Level.SEVERE, msg, e); throw new SecurityException(msg, e); diff --git a/src/java/org/rapidcontext/util/BinaryUtil.java b/src/java/org/rapidcontext/util/BinaryUtil.java index a9819357..9b8acb58 100644 --- a/src/java/org/rapidcontext/util/BinaryUtil.java +++ b/src/java/org/rapidcontext/util/BinaryUtil.java @@ -16,7 +16,6 @@ import java.io.IOException; import java.io.InputStream; -import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -41,11 +40,9 @@ public final class BinaryUtil { * * @throws NoSuchAlgorithmException if the MD5 algorithm isn't * available (should be RuntimeException) - * @throws UnsupportedEncodingException if the UTF-8 encoding isn't - * available (should be RuntimeException) */ public static String hashMD5(String input) - throws NoSuchAlgorithmException, UnsupportedEncodingException { + throws NoSuchAlgorithmException { return encodeHexString(hashBytes("MD5", input.getBytes(StandardCharsets.UTF_8))); } @@ -59,11 +56,9 @@ public static String hashMD5(String input) * * @throws NoSuchAlgorithmException if the SHA-256 algorithm isn't * available (should be RuntimeException) - * @throws UnsupportedEncodingException if the UTF-8 encoding isn't - * available (should be RuntimeException) */ public static String hashSHA256(String input) - throws NoSuchAlgorithmException, UnsupportedEncodingException { + throws NoSuchAlgorithmException { return encodeHexString(hashBytes("SHA-256", input.getBytes(StandardCharsets.UTF_8))); } diff --git a/src/java/org/rapidcontext/util/ClasspathUtil.java b/src/java/org/rapidcontext/util/ClasspathUtil.java index fe911a41..1efba169 100644 --- a/src/java/org/rapidcontext/util/ClasspathUtil.java +++ b/src/java/org/rapidcontext/util/ClasspathUtil.java @@ -15,7 +15,6 @@ package org.rapidcontext.util; import java.io.File; -import java.io.UnsupportedEncodingException; import java.net.JarURLConnection; import java.net.URL; import java.net.URLDecoder;