diff --git a/app/src/main/java/io/apicurio/registry/rest/RegistryApplicationServletFilter.java b/app/src/main/java/io/apicurio/registry/rest/RegistryApplicationServletFilter.java index 64ab68349c..c10437a04a 100644 --- a/app/src/main/java/io/apicurio/registry/rest/RegistryApplicationServletFilter.java +++ b/app/src/main/java/io/apicurio/registry/rest/RegistryApplicationServletFilter.java @@ -24,7 +24,6 @@ import io.apicurio.registry.services.DisabledApisMatcherService; import io.apicurio.registry.services.http.ErrorHttpResponse; import io.apicurio.registry.services.http.RegistryExceptionMapperService; -import io.apicurio.registry.types.WrappedRegistryException; import io.apicurio.tenantmanager.api.datamodel.TenantStatusValue; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; @@ -153,10 +152,6 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha private void mapException(ServletResponse response, Throwable throwable) throws IOException { - if (throwable instanceof WrappedRegistryException) { - throwable = ((WrappedRegistryException) throwable).getWrapped(); - } - ErrorHttpResponse res = exceptionMapper.mapException(throwable); HttpServletResponse httpResponse = (HttpServletResponse) response; httpResponse.reset(); diff --git a/app/src/main/java/io/apicurio/registry/rest/RegistryExceptionMapper.java b/app/src/main/java/io/apicurio/registry/rest/RegistryExceptionMapper.java index 74b0064b73..631ae5f5ad 100644 --- a/app/src/main/java/io/apicurio/registry/rest/RegistryExceptionMapper.java +++ b/app/src/main/java/io/apicurio/registry/rest/RegistryExceptionMapper.java @@ -23,7 +23,6 @@ import io.apicurio.registry.services.http.ErrorHttpResponse; import io.apicurio.registry.services.http.RegistryExceptionMapperService; import io.apicurio.registry.storage.error.*; -import io.apicurio.registry.types.WrappedRegistryException; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import jakarta.servlet.http.HttpServletRequest; @@ -80,10 +79,6 @@ public class RegistryExceptionMapper implements ExceptionMapper { @Override public Response toResponse(Throwable t) { - if (t instanceof WrappedRegistryException) { - t = ((WrappedRegistryException) t).getWrapped(); - } - ErrorHttpResponse res = exceptionMapper.mapException(t); Response.ResponseBuilder builder; diff --git a/app/src/test/java/io/apicurio/registry/storage/ReadOnlyRegistryStorageTest.java b/app/src/test/java/io/apicurio/registry/storage/ReadOnlyRegistryStorageTest.java index 3e96df1136..7503fe2ab1 100644 --- a/app/src/test/java/io/apicurio/registry/storage/ReadOnlyRegistryStorageTest.java +++ b/app/src/test/java/io/apicurio/registry/storage/ReadOnlyRegistryStorageTest.java @@ -20,7 +20,6 @@ import io.apicurio.common.apps.config.DynamicConfigStorage; import io.apicurio.registry.storage.error.ReadOnlyStorageException; import io.apicurio.registry.types.Current; -import io.apicurio.registry.types.WrappedRegistryException; import io.apicurio.registry.utils.Functional.Runnable1Ex; import io.apicurio.registry.utils.tests.ApicurioTestTags; import io.quarkus.test.junit.QuarkusTest; @@ -195,9 +194,6 @@ private void notEnabled() { try { state.runnable.run(storage); } catch (Exception ex) { - if (ex instanceof WrappedRegistryException) { - ex = ((WrappedRegistryException) ex).getWrapped(); - } if (ex instanceof ReadOnlyStorageException) { Assertions.fail("Unexpected ReadOnlyStorageException for method " + method + " (read-only is not enabled).", ex); } @@ -219,9 +215,6 @@ private void enabled() { Assertions.fail("Expected ReadOnlyStorageException for method " + method + " (read-only is enabled)."); } } catch (Exception ex) { - if (ex instanceof WrappedRegistryException) { - ex = ((WrappedRegistryException) ex).getWrapped(); - } if (ex instanceof ReadOnlyStorageException) { if (!state.writes) { Assertions.fail("Unexpected ReadOnlyStorageException for method " + method + " (read-only is enabled).", ex); diff --git a/common/src/main/java/io/apicurio/registry/types/WrappedRegistryException.java b/common/src/main/java/io/apicurio/registry/types/WrappedRegistryException.java deleted file mode 100644 index 0cf4f6b39d..0000000000 --- a/common/src/main/java/io/apicurio/registry/types/WrappedRegistryException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2020 Red Hat - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.apicurio.registry.types; - -import lombok.Getter; - -/** - * This exception is used to wrap a checked Registry exception into an unchecked one. - *

- * This is used, for example, to throw {@see io.apicurio.registry.storage.error.CheckedRegistryStorageException} - * from the REST API methods, until the codegen supports checked exceptions. - * We can't use @SneakyThrows(ReadOnlyStorageException.class) because Arc will throw - * an {@see io.quarkus.arc.ArcUndeclaredThrowableException}. - * - * @author Jakub Senko m@jsenko.net - */ -public class WrappedRegistryException extends RuntimeException { - - private static final long serialVersionUID = -6439379373254391061L; - - @Getter - private CheckedRegistryException wrapped; - - private WrappedRegistryException(CheckedRegistryException wrapped) { - super(wrapped); - this.wrapped = wrapped; - } - - public static WrappedRegistryException wrap(CheckedRegistryException ex) { - return new WrappedRegistryException(ex); - } -}