You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/03/17 21:38:15 UTC

[GitHub] [pinot] richardstartin commented on a change in pull request #8329: Refactor Pinot http utils into HttpClient

richardstartin commented on a change in pull request #8329:
URL: https://github.com/apache/pinot/pull/8329#discussion_r829533085



##########
File path: pinot-common/src/main/java/org/apache/pinot/common/utils/TlsUtils.java
##########
@@ -255,6 +257,14 @@ public static URL makeKeyStoreUrl(String storePath)
     return inputUri.toURL();
   }
 
+  public static SSLContext getSslContext() {
+    return _sslContext != null ? _sslContext : SSLContexts.createDefault();

Review comment:
       I suggest putting it in a holder class:
   
   ```java
   private static final AtomicReference<SSLContext> OVERRIDE = new AtomicReference<>();
   
   public static void registerOverride(SSLContext override) {
       if (!OVERRIDE.compareAndSet(null, override)) {
          // warn that something else beat the caller here
       }
   }
   
   private static final class Holder {
       static final SSLContext SSL_CONTEXT = OVERRIDE.get() == null ? SSLContexts.createDefault() : OVERRIDE.get();
   }
   ```
   
   And then reference it via `Holder.SSL_CONTEXT` everywhere. This has a few advantages:
   
   * registration is thread safe
   * mutable until first use
   * synchronization, at most once initialisation guaranteed by the classloader
   * after initialisation, the `SSLContext` is constant which can drive optimisations like constant folding, which may or may not be important




-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org