You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by br...@apache.org on 2023/11/13 11:35:35 UTC

(solr-sandbox) branch main updated: Encryption KeySupplier extends Closeable. (#84)

This is an automated email from the ASF dual-hosted git repository.

broustant pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr-sandbox.git


The following commit(s) were added to refs/heads/main by this push:
     new 2f923d4  Encryption KeySupplier extends Closeable. (#84)
2f923d4 is described below

commit 2f923d42b9de9f8363e7d670e254fe9b935d5c32
Author: Bruno Roustant <33...@users.noreply.github.com>
AuthorDate: Mon Nov 13 12:35:30 2023 +0100

    Encryption KeySupplier extends Closeable. (#84)
---
 .../java/org/apache/solr/encryption/EncryptionDirectoryFactory.java | 6 ++++++
 .../src/main/java/org/apache/solr/encryption/KeySupplier.java       | 3 ++-
 .../test/java/org/apache/solr/encryption/TestingKeySupplier.java    | 3 +++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/encryption/src/main/java/org/apache/solr/encryption/EncryptionDirectoryFactory.java b/encryption/src/main/java/org/apache/solr/encryption/EncryptionDirectoryFactory.java
index f24cd8c..ad51886 100644
--- a/encryption/src/main/java/org/apache/solr/encryption/EncryptionDirectoryFactory.java
+++ b/encryption/src/main/java/org/apache/solr/encryption/EncryptionDirectoryFactory.java
@@ -135,6 +135,12 @@ public class EncryptionDirectoryFactory extends MMapDirectoryFactory {
     return innerFactory.create(super.create(path, lockFactory, dirContext), getEncrypterFactory(), getKeySupplier());
   }
 
+  @Override
+  public void close() throws IOException {
+    keySupplier.close();
+    super.close();
+  }
+
   /**
    * Visible for tests only - Inner factory that creates {@link EncryptionDirectory} instances.
    */
diff --git a/encryption/src/main/java/org/apache/solr/encryption/KeySupplier.java b/encryption/src/main/java/org/apache/solr/encryption/KeySupplier.java
index fbee227..6a533df 100644
--- a/encryption/src/main/java/org/apache/solr/encryption/KeySupplier.java
+++ b/encryption/src/main/java/org/apache/solr/encryption/KeySupplier.java
@@ -21,6 +21,7 @@ import org.apache.solr.common.util.NamedList;
 import org.apache.solr.util.plugin.NamedListInitializedPlugin;
 
 import javax.annotation.Nullable;
+import java.io.Closeable;
 import java.io.IOException;
 import java.util.Map;
 import java.util.function.Function;
@@ -28,7 +29,7 @@ import java.util.function.Function;
 /**
  * Provides encryption key secrets corresponding to provided key ids and defines which index files to encrypt.
  */
-public interface KeySupplier {
+public interface KeySupplier extends Closeable {
 
   /**
    * Indicates whether the provided file should be encrypted based on its name.
diff --git a/encryption/src/test/java/org/apache/solr/encryption/TestingKeySupplier.java b/encryption/src/test/java/org/apache/solr/encryption/TestingKeySupplier.java
index f1ec0f9..6c4556e 100644
--- a/encryption/src/test/java/org/apache/solr/encryption/TestingKeySupplier.java
+++ b/encryption/src/test/java/org/apache/solr/encryption/TestingKeySupplier.java
@@ -166,6 +166,9 @@ public class TestingKeySupplier implements KeySupplier {
     return secret;
   }
 
+  @Override
+  public void close() {}
+
   /**
    * Supplies the {@link TestingKeySupplier} singleton.
    */