Galsza commented on code in PR #5157:
URL: https://github.com/apache/ozone/pull/5157#discussion_r1288445693


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMCertStore.java:
##########
@@ -223,33 +223,41 @@ public void removeExpiredCertificate(BigInteger serialID)
   }
 
   @Override
-  public void removeAllExpiredCertificates() throws IOException {
+  public List<X509Certificate> removeAllExpiredCertificates()
+      throws IOException {
+    List<X509Certificate> removedCerts = new ArrayList<>();
     lock.lock();
     try (BatchOperation batchOperation =
              scmMetadataStore.getBatchHandler().initBatchOperation()) {
-      addExpiredCertsToBeRemoved(batchOperation,
-          scmMetadataStore.getValidCertsTable());
-      addExpiredCertsToBeRemoved(batchOperation,
-          scmMetadataStore.getValidSCMCertsTable());
+      removedCerts.addAll(addExpiredCertsToBeRemoved(batchOperation,
+          scmMetadataStore.getValidCertsTable()));
+      removedCerts.addAll(addExpiredCertsToBeRemoved(batchOperation,
+          scmMetadataStore.getValidSCMCertsTable()));
       scmMetadataStore.getStore().commitBatchOperation(batchOperation);
     } finally {
       lock.unlock();
     }
+    return removedCerts;
   }
 
-  private void addExpiredCertsToBeRemoved(BatchOperation batchOperation,
-      Table<BigInteger, X509Certificate> certTable) throws IOException {
+  private List<X509Certificate> addExpiredCertsToBeRemoved(
+      BatchOperation batchOperation, Table<BigInteger,
+      X509Certificate> certTable) throws IOException {
+    List<X509Certificate> removedCerts = new ArrayList<>();
     try (TableIterator<BigInteger, ? extends Table.KeyValue<BigInteger,
         X509Certificate>> certsIterator = certTable.iterator()) {
       Instant now = Instant.now();
       while (certsIterator.hasNext()) {
         Table.KeyValue<BigInteger, X509Certificate> certEntry =
             certsIterator.next();
-        if (certEntry.getValue().getNotAfter().toInstant().isBefore(now)) {
+        X509Certificate cert = certEntry.getValue();
+        if (cert.getNotAfter().toInstant().isBefore(now)) {

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to