exceptionfactory commented on code in PR #6931:
URL: https://github.com/apache/nifi/pull/6931#discussion_r1100625685


##########
nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/JettyServer.java:
##########
@@ -147,9 +151,39 @@ private File getDocsDir(final String docsDirectory) {
     }
 
     private void configureConnectors() {
-        final ServerConnectorFactory serverConnectorFactory = new 
ApplicationServerConnectorFactory(server, properties);
-        final ServerConnector serverConnector = 
serverConnectorFactory.getServerConnector();
-        server.addConnector(serverConnector);
+        try {
+            final ServerConnectorFactory serverConnectorFactory = new 
ApplicationServerConnectorFactory(server, properties);
+            final Map<String, String> interfaces = 
properties.isHTTPSConfigured() ? properties.getHttpsNetworkInterfaces() : 
Collections.emptyMap();
+            final Set<String> interfaceNames = 
interfaces.values().stream().filter(StringUtils::isNotBlank).collect(Collectors.toSet());
+            if (properties.isHTTPSConfigured() && !interfaceNames.isEmpty()) {
+                interfaceNames.stream()
+                        // Map interface name properties to Network Interfaces
+                        .map(interfaceName -> {
+                            try {
+                                logger.error("Checking {}", interfaceName);

Review Comment:
   This error log should be removed.



##########
nifi-registry/nifi-registry-core/nifi-registry-properties/src/main/java/org/apache/nifi/registry/properties/NiFiRegistryProperties.java:
##########
@@ -479,4 +483,25 @@ public String getOidcClaimIdentifyingUser() {
         return getProperty(SECURITY_USER_OIDC_CLAIM_IDENTIFYING_USER, 
"email").trim();
     }
 
+    /**
+     * Returns the network interface list to use for HTTPS. This method 
returns a mapping of
+     * network interface property names to network interface names.
+     *
+     * @return the property name and network interface name of all HTTPS 
network interfaces
+     */
+    public Map<String, String> getHttpsNetworkInterfaces() {

Review Comment:
   As the only usage of this method does not use the property names, it looks 
like this could be simplified to just return a `Set<String>` of interface names 
that are not blank.
   ```suggestion
       public Set<String> getHttpsNetworkInterfaceNames() {
   ```



##########
nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/JettyServer.java:
##########
@@ -147,9 +151,39 @@ private File getDocsDir(final String docsDirectory) {
     }
 
     private void configureConnectors() {
-        final ServerConnectorFactory serverConnectorFactory = new 
ApplicationServerConnectorFactory(server, properties);
-        final ServerConnector serverConnector = 
serverConnectorFactory.getServerConnector();
-        server.addConnector(serverConnector);
+        try {

Review Comment:
   This outer try-catch block is unnecessary because `configureConnectors()` is 
already called from a try-catch with the same handling.



##########
nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/JettyServer.java:
##########
@@ -147,9 +151,39 @@ private File getDocsDir(final String docsDirectory) {
     }
 
     private void configureConnectors() {
-        final ServerConnectorFactory serverConnectorFactory = new 
ApplicationServerConnectorFactory(server, properties);
-        final ServerConnector serverConnector = 
serverConnectorFactory.getServerConnector();
-        server.addConnector(serverConnector);
+        try {
+            final ServerConnectorFactory serverConnectorFactory = new 
ApplicationServerConnectorFactory(server, properties);
+            final Map<String, String> interfaces = 
properties.isHTTPSConfigured() ? properties.getHttpsNetworkInterfaces() : 
Collections.emptyMap();
+            final Set<String> interfaceNames = 
interfaces.values().stream().filter(StringUtils::isNotBlank).collect(Collectors.toSet());
+            if (properties.isHTTPSConfigured() && !interfaceNames.isEmpty()) {

Review Comment:
   Recommend simplifying and reversing the logic. The 
`properties.isHTTPConfigured()` check is called above, so it does not need to 
be checked again.
   ```suggestion
               if (interfaceNames.isEmpty()) {
                   // serverConnectorFactory.getServerConnector()
               } else {
                   // stream through interface names
               }
   ```



-- 
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]

Reply via email to