vamossagar12 commented on code in PR #15149:
URL: https://github.com/apache/kafka/pull/15149#discussion_r1446980325


##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/HerderRequestHandler.java:
##########
@@ -41,18 +41,11 @@ public class HerderRequestHandler {
 
     private final RestClient restClient;
 
-    private volatile long requestTimeoutMs;
+    private final RestRequestTimeout requestTimeout;

Review Comment:
   The field `requestTimeoutMs` was made volatile as part of 
[here](https://github.com/apache/kafka/pull/14562/files#diff-f2311f0c356f882d7768b97cb5f0054dc7040d29d455eab74ab585725454488aR44).
 I don't think we need it now, but just wanted to understand why was it added 
over there (you can skip the explanation if it's too complex :) )



##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/HerderRequestHandler.java:
##########
@@ -41,18 +41,11 @@ public class HerderRequestHandler {
 
     private final RestClient restClient;
 
-    private volatile long requestTimeoutMs;
+    private final RestRequestTimeout requestTimeout;
 
-    public HerderRequestHandler(RestClient restClient, long requestTimeoutMs) {
+    public HerderRequestHandler(RestClient restClient, RestRequestTimeout 
requestTimeout) {
         this.restClient = restClient;
-        this.requestTimeoutMs = requestTimeoutMs;
-    }
-
-    public void requestTimeoutMs(long requestTimeoutMs) {
-        if (requestTimeoutMs < 1) {
-            throw new IllegalArgumentException("REST request timeout must be 
positive");
-        }

Review Comment:
   I am not sure if this validation was needed in the past as well, but now I 
don't see it being present. Do you think it's needed?



##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/ConnectRestServer.java:
##########
@@ -45,25 +45,40 @@ public void initializeResources(Herder herder) {
     }
 
     @Override
-    protected Collection<ConnectResource> regularResources() {
+    protected Collection<Class<?>> regularResources() {
         return Arrays.asList(
-                new RootResource(herder),
-                new ConnectorsResource(herder, config, restClient),
-                new InternalConnectResource(herder, restClient),
-                new ConnectorPluginsResource(herder)
+                RootResource.class,
+                ConnectorsResource.class,
+                InternalConnectResource.class,
+                ConnectorPluginsResource.class
         );
     }
 
     @Override
-    protected Collection<ConnectResource> adminResources() {
+    protected Collection<Class<?>> adminResources() {
         return Arrays.asList(
-                new LoggingResource(herder)
+                LoggingResource.class
         );
     }
 
     @Override
     protected void configureRegularResources(ResourceConfig resourceConfig) {
         registerRestExtensions(herder, resourceConfig);
+        resourceConfig.register(new Binder());
+    }
+
+    private class Binder extends AbstractBinder {
+        @Override
+        protected void configure() {
+            bind(herder).to(Herder.class);
+            bind(restClient).to(RestClient.class);
+            bind(config).to(RestServerConfig.class);
+        }
+    }
+

Review Comment:
   nit: We could probably move the class definition to the bottom so that all 
`configureXXXResources` method are together



##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestRequestTimeout.java:
##########
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.connect.runtime.rest;
+
+public interface RestRequestTimeout {

Review Comment:
   nit: Mark this interface as `@FunctionalInterface`?



-- 
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: jira-unsubscr...@kafka.apache.org

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

Reply via email to