From a01b1087d29e8d9146d786cf83f8b9cedd3da85f Mon Sep 17 00:00:00 2001 From: translatenix <119817707+translatenix@users.noreply.github.com> Date: Wed, 21 Feb 2024 12:19:33 -0800 Subject: [PATCH] Rename class --- .../main/java/org/pkl/core/http/JdkHttpClient.java | 12 ++++++------ .../util/{ExceptionUtils.java => Exceptions.java} | 4 ++-- .../{ExceptionUtilsTest.kt => ExceptionsTest.kt} | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) rename pkl-core/src/main/java/org/pkl/core/util/{ExceptionUtils.java => Exceptions.java} (94%) rename pkl-core/src/test/kotlin/org/pkl/core/util/{ExceptionUtilsTest.kt => ExceptionsTest.kt} (67%) diff --git a/pkl-core/src/main/java/org/pkl/core/http/JdkHttpClient.java b/pkl-core/src/main/java/org/pkl/core/http/JdkHttpClient.java index 62edc1d06..b5a3a0bc6 100644 --- a/pkl-core/src/main/java/org/pkl/core/http/JdkHttpClient.java +++ b/pkl-core/src/main/java/org/pkl/core/http/JdkHttpClient.java @@ -49,7 +49,7 @@ import javax.net.ssl.SSLHandshakeException; import javax.net.ssl.TrustManagerFactory; import org.pkl.core.util.ErrorMessages; -import org.pkl.core.util.ExceptionUtils; +import org.pkl.core.util.Exceptions; @ThreadSafe final class JdkHttpClient implements HttpClient { @@ -94,7 +94,7 @@ public HttpResponse send(HttpRequest request, BodyHandler responseBody } catch (SSLHandshakeException e) { throw new SSLHandshakeException( ErrorMessages.create( - "errorSslHandshake", request.uri().getHost(), ExceptionUtils.getRootReason(e))); + "errorSslHandshake", request.uri().getHost(), Exceptions.getRootReason(e))); } catch (InterruptedException e) { // next best thing after letting (checked) InterruptedException bubble up Thread.currentThread().interrupt(); @@ -140,7 +140,7 @@ private static SSLContext createSslContext( return sslContext; } catch (GeneralSecurityException e) { throw new HttpClientInitException( - ErrorMessages.create("cannotInitHttpClient", ExceptionUtils.getRootReason(e)), e); + ErrorMessages.create("cannotInitHttpClient", Exceptions.getRootReason(e)), e); } } @@ -155,7 +155,7 @@ private static Set createTrustAnchors( throw new HttpClientInitException(ErrorMessages.create("cannotFindCertFile", file)); } catch (IOException e) { throw new HttpClientInitException( - ErrorMessages.create("cannotReadCertFile", ExceptionUtils.getRootReason(e))); + ErrorMessages.create("cannotReadCertFile", Exceptions.getRootReason(e))); } } @@ -164,7 +164,7 @@ private static Set createTrustAnchors( collectTrustAnchors(anchors, factory, stream, url); } catch (IOException e) { throw new HttpClientInitException( - ErrorMessages.create("cannotReadCertFile", ExceptionUtils.getRootReason(e))); + ErrorMessages.create("cannotReadCertFile", Exceptions.getRootReason(e))); } } @@ -182,7 +182,7 @@ private static void collectTrustAnchors( certificates = (Collection) factory.generateCertificates(stream); } catch (CertificateException e) { throw new HttpClientInitException( - ErrorMessages.create("cannotParseCertFile", source, ExceptionUtils.getRootReason(e))); + ErrorMessages.create("cannotParseCertFile", source, Exceptions.getRootReason(e))); } if (certificates.isEmpty()) { throw new HttpClientInitException(ErrorMessages.create("emptyCertFile", source)); diff --git a/pkl-core/src/main/java/org/pkl/core/util/ExceptionUtils.java b/pkl-core/src/main/java/org/pkl/core/util/Exceptions.java similarity index 94% rename from pkl-core/src/main/java/org/pkl/core/util/ExceptionUtils.java rename to pkl-core/src/main/java/org/pkl/core/util/Exceptions.java index f56943bb6..990736ea5 100644 --- a/pkl-core/src/main/java/org/pkl/core/util/ExceptionUtils.java +++ b/pkl-core/src/main/java/org/pkl/core/util/Exceptions.java @@ -15,8 +15,8 @@ */ package org.pkl.core.util; -public final class ExceptionUtils { - private ExceptionUtils() {} +public final class Exceptions { + private Exceptions() {} public static Throwable getRootCause(Throwable t) { var result = t; diff --git a/pkl-core/src/test/kotlin/org/pkl/core/util/ExceptionUtilsTest.kt b/pkl-core/src/test/kotlin/org/pkl/core/util/ExceptionsTest.kt similarity index 67% rename from pkl-core/src/test/kotlin/org/pkl/core/util/ExceptionUtilsTest.kt rename to pkl-core/src/test/kotlin/org/pkl/core/util/ExceptionsTest.kt index 45ee769d5..e464768dd 100644 --- a/pkl-core/src/test/kotlin/org/pkl/core/util/ExceptionUtilsTest.kt +++ b/pkl-core/src/test/kotlin/org/pkl/core/util/ExceptionsTest.kt @@ -5,11 +5,11 @@ import org.junit.jupiter.api.Test import java.io.IOException import java.lang.Error -class ExceptionUtilsTest { +class ExceptionsTest { @Test fun `get root cause of simple exception`() { val e = IOException("io") - assertThat(ExceptionUtils.getRootCause(e)).isSameAs(e) + assertThat(Exceptions.getRootCause(e)).isSameAs(e) } @Test @@ -19,7 +19,7 @@ class ExceptionUtilsTest { val e3 = Error("error") e.initCause(e2) e2.initCause(e3) - assertThat(ExceptionUtils.getRootCause(e)).isSameAs(e3) + assertThat(Exceptions.getRootCause(e)).isSameAs(e3) } @Test @@ -27,7 +27,7 @@ class ExceptionUtilsTest { val e = IOException("io") val e2 = RuntimeException("the root reason") e.initCause(e2) - assertThat(ExceptionUtils.getRootReason(e)).isEqualTo("the root reason") + assertThat(Exceptions.getRootReason(e)).isEqualTo("the root reason") } @Test @@ -35,7 +35,7 @@ class ExceptionUtilsTest { val e = IOException("io") val e2 = RuntimeException(null as String?) e.initCause(e2) - assertThat(ExceptionUtils.getRootReason(e)).isEqualTo("(unknown reason)") + assertThat(Exceptions.getRootReason(e)).isEqualTo("(unknown reason)") } @Test @@ -43,6 +43,6 @@ class ExceptionUtilsTest { val e = IOException("io") val e2 = RuntimeException("") e.initCause(e2) - assertThat(ExceptionUtils.getRootReason(e)).isEqualTo("(unknown reason)") + assertThat(Exceptions.getRootReason(e)).isEqualTo("(unknown reason)") } }