Skip to content

Commit

Permalink
Use AutoCloseableDestroyer for the standalone search mapping bean
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-bekhta committed Jun 20, 2024
1 parent ed77ee2 commit ab47d55
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ void defineSearchMappingBean(Optional<HibernateSearchStandaloneEnabledBuildItem>
.setRuntimeInit()
.createWith(recorder.createSearchMappingFunction(runtimeConfig,
enabled.get().getBackendAndIndexNamesForSearchExtensions()))
.destroyer(BeanDestroyer.CloseableDestroyer.class)
.destroyer(BeanDestroyer.AutoCloseableDestroyer.class)
.done());
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.keycloak.json.StringOrArrayDeserializer;
import org.keycloak.json.StringOrArraySerializer;

import io.quarkus.arc.BeanDestroyer;
import io.quarkus.arc.deployment.SyntheticBeanBuildItem;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
Expand All @@ -21,7 +22,6 @@
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyIgnoreWarningBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
import io.quarkus.keycloak.admin.client.common.AutoCloseableDestroyer;
import io.quarkus.keycloak.admin.client.common.KeycloakAdminClientInjectionEnabled;
import io.quarkus.keycloak.admin.client.reactive.runtime.ResteasyReactiveClientProvider;
import io.quarkus.keycloak.admin.client.reactive.runtime.ResteasyReactiveKeycloakAdminClientRecorder;
Expand Down Expand Up @@ -69,7 +69,7 @@ public void registerKeycloakAdminClientBeans(ResteasyReactiveKeycloakAdminClient
.defaultBean()
.unremovable()
.supplier(recorder.createAdminClient())
.destroyer(AutoCloseableDestroyer.class)
.destroyer(BeanDestroyer.AutoCloseableDestroyer.class)
.done());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.keycloak.json.StringOrArrayDeserializer;
import org.keycloak.json.StringOrArraySerializer;

import io.quarkus.arc.BeanDestroyer;
import io.quarkus.arc.deployment.SyntheticBeanBuildItem;
import io.quarkus.deployment.Capabilities;
import io.quarkus.deployment.Capability;
Expand All @@ -24,7 +25,6 @@
import io.quarkus.deployment.builditem.ServiceStartBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyIgnoreWarningBuildItem;
import io.quarkus.keycloak.admin.client.common.AutoCloseableDestroyer;
import io.quarkus.keycloak.admin.client.common.KeycloakAdminClientInjectionEnabled;
import io.quarkus.keycloak.adminclient.ResteasyKeycloakAdminClientRecorder;

Expand Down Expand Up @@ -68,7 +68,7 @@ public void registerKeycloakAdminClientBeans(ResteasyKeycloakAdminClientRecorder
.defaultBean()
.unremovable()
.supplier(recorder.createAdminClient())
.destroyer(AutoCloseableDestroyer.class)
.destroyer(BeanDestroyer.AutoCloseableDestroyer.class)
.done());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,16 @@ public void destroy(Closeable instance, CreationalContext<Closeable> creationalC
}
}

class AutoCloseableDestroyer implements BeanDestroyer<AutoCloseable> {
@Override
public void destroy(AutoCloseable instance, CreationalContext<AutoCloseable> creationalContext,
Map<String, Object> params) {
try {
instance.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

}

0 comments on commit ab47d55

Please sign in to comment.