Catch any error and log during enclave creation.
@@ -15,11 +15,9 @@ import com.quorum.tessera.encryption.EncryptorFactory;
import java.util.Collection;
import java.util.Optional;
+import org.slf4j.LoggerFactory;
-/**
- * Creates {@link Enclave} instances, which may point to remote services or
- * local, in-app instances.
- */
+/** Creates {@link Enclave} instances, which may point to remote services or local, in-app instances. */
public interface EnclaveFactory {
default Enclave createLocal(Config config) {
@@ -41,21 +39,18 @@ public interface EnclaveFactory {
}
/**
- * Determines from the provided configuration whether to construct a client
- * to a remote service, or to create a local instance.
+ * Determines from the provided configuration whether to construct a client to a remote service, or to create a
+ * local instance.
*
- * <p>
- * If a remote instance is requested, it is constructed from a
- * {@link EnclaveClientFactory}.
+ * <p>If a remote instance is requested, it is constructed from a {@link EnclaveClientFactory}.
*
- * @param config the global configuration to use to create a remote enclave
- * connection
+ * @param config the global configuration to use to create a remote enclave connection
* @return the {@link Enclave}, which may be either local or remote
*/
default Enclave create(Config config) {
-
- final Optional<ServerConfig> enclaveServerConfig
- = config.getServerConfigs().stream().filter(sc -> sc.getApp() == AppType.ENCLAVE).findAny();
+ try {
+ final Optional<ServerConfig> enclaveServerConfig =
+ config.getServerConfigs().stream().filter(sc -> sc.getApp() == AppType.ENCLAVE).findAny();
// FIXME: this is needs to create a holder instance .
KeyEncryptorFactory.newFactory().create(config.getEncryptor());
@@ -65,11 +60,13 @@ public interface EnclaveFactory {
}
return createServer(config);
-
+ } catch (Throwable ex) {
+ LoggerFactory.getLogger(EnclaveFactory.class).error("", ex);
+ throw ex;
+ }
}
static EnclaveFactory create() {
- return ServiceLoaderUtil.load(EnclaveFactory.class).orElse(new EnclaveFactory() {
- });
+ return ServiceLoaderUtil.load(EnclaveFactory.class).orElse(new EnclaveFactory() {});
}
}
