ronantakizawa/codereview-bench huggingface dataset:
Repository: apache/kafka
File: streams/src/main/java/org/apache/kafka/streams/processor/RecordContext.java (Java)

Code before:
     */
    Headers headers();

    /**
     * Return the non-deserialized byte[] of the input message key if the context has been triggered by a message.
     *
     * <p> If this method is invoked within a {@link Punctuator#punctuate(long)
     * punctuation callback}, or while processing a record that was forwarded by a punctuation
     * callback, it will return null.
     *
     * <p> If this method is invoked in a sub-topology due to a repartition, the returned key would be one sent
     * to the repartition topic.
     *
     * <p> Always returns null if this method is invoked within a
     * ProductionExceptionHandler.handle(ErrorHandlerContext, ProducerRecord, Exception)
     *
     * @return the raw byte of the key of the source message
     */
    byte[] sourceRawKey();

    /**
     * Return the non-deserialized byte[] of the input message value if the context has been triggered by a message.
     *
     * <p> If this method is invoked within a {@link Punctuator#punctuate(long)
     * punctuation callback}, or while processing a record that was forwarded by a punctuation
     * callback, it will return null.
     *
     * <p> If this method is invoked in a sub-topology due to a repartition, the returned key would be one sent
     * to the repartition topic.
     *
     * <p> Always returns null if this method is invoked within a
     * ProductionExceptionHandler.handle(ErrorHandlerContext, ProducerRecord, Exception)
     *
     * @return the raw byte of the value of the source message
     */
    byte[] sourceRawValue();
}


Review comment (suggestion):
nit:
```suggestion
     * callback, it will return {@code null}.
```

Code after:
     */
    Headers headers();

    /**
     * Return the non-deserialized byte[] of the input message key if the context has been triggered by a message.
     *
     * <p> If this method is invoked within a {@link Punctuator#punctuate(long)
     * punctuation callback}, or while processing a record that was forwarded by a punctuation
     * callback, it will return {@code null}.
     *
     * <p> If this method is invoked in a sub-topology due to a repartition, the returned key would be one sent
     * to the repartition topic.
     *
     * @return the raw byte of the key of the source message
     */
    byte[] sourceRawKey();

    /**
     * Return the non-deserialized byte[] of the input message value if the context has been triggered by a message.
     *
     * <p> If this method is invoked within a {@link Punctuator#punctuate(long)
     * punctuation callback}, or while processing a record that was forwarded by a punctuation
     * callback, it will return {@code null}.
     *
     * <p> If this method is invoked in a sub-topology due to a repartition, the returned key would be one sent
     * to the repartition topic.
     *
     * @return the raw byte of the value of the source message
     */
    byte[] sourceRawValue();
}
Repository: apache/kafka
File: core/src/main/scala/kafka/raft/RaftManager.scala (Scala)

Code before:
      .map(Paths.get(_).toAbsolutePath)
      .contains(Paths.get(config.metadataLogDir).toAbsolutePath)
  }
}

trait RaftManager[T] {
  def handleRequest(
    context: RequestContext,
    header: RequestHeader,
    request: ApiMessage,
    createdTimeMs: Long
  ): CompletableFuture[ApiMessage]

  def register(
    listener: RaftClient.Listener[T]
  ): Unit

  def leaderAndEpoch: LeaderAndEpoch

  def client: RaftClient[T]

  def replicatedLog: ReplicatedLog

  def voterNode(id: Int, listener: ListenerName): Option[Node]

  def getRecordSerde: RecordSerde[T]
}

class KafkaRaftManager[T](
  clusterId: String,
  config: KafkaConfig,
  metadataLogDirUuid: Uuid,
  recordSerde: RecordSerde[T],
  topicPartition: TopicPartition,
  topicId: Uuid,
  time: Time,
  metrics: Metrics,
  externalKRaftMetrics: ExternalKRaftMetrics,
  threadNamePrefixOpt: Option[String],
  val controllerQuorumVotersFuture: CompletableFuture[JMap[Integer, InetSocketAddress]],
  bootstrapServers: JCollection[InetSocketAddress],
  localListeners: Endpoints,
  fatalFaultHandler: FaultHandler
) extends RaftManager[T] with Logging {

  val apiVersions = new ApiVersions()
  private val raftConfig = new QuorumConfig(config)
  private val threadNamePrefix = threadNamePrefixOpt.getOrElse("kafka-raft")
  private val logContext = new LogContext(s"[RaftManager id=${config.nodeId}] ")
  this.logIdent = logContext.logPrefix()


Review comment (suggestion):
In Kafka we generally don't put 'get' in front of getters. So this method should just be `recordSerde`

Code after:
      .map(Paths.get(_).toAbsolutePath)
      .contains(Paths.get(config.metadataLogDir).toAbsolutePath)
  }
}

trait RaftManager[T] {
  def handleRequest(
    context: RequestContext,
    header: RequestHeader,
    request: ApiMessage,
    createdTimeMs: Long
  ): CompletableFuture[ApiMessage]

  def register(
    listener: RaftClient.Listener[T]
  ): Unit

  def leaderAndEpoch: LeaderAndEpoch

  def client: RaftClient[T]

  def replicatedLog: ReplicatedLog

  def voterNode(id: Int, listener: ListenerName): Option[Node]

  def recordSerde: RecordSerde[T]
}

class KafkaRaftManager[T](
  clusterId: String,
  config: KafkaConfig,
  metadataLogDirUuid: Uuid,
  serde: RecordSerde[T],
  topicPartition: TopicPartition,
  topicId: Uuid,
  time: Time,
  metrics: Metrics,
  externalKRaftMetrics: ExternalKRaftMetrics,
  threadNamePrefixOpt: Option[String],
  val controllerQuorumVotersFuture: CompletableFuture[JMap[Integer, InetSocketAddress]],
  bootstrapServers: JCollection[InetSocketAddress],
  localListeners: Endpoints,
  fatalFaultHandler: FaultHandler
) extends RaftManager[T] with Logging {

  val apiVersions = new ApiVersions()
  private val raftConfig = new QuorumConfig(config)
  private val threadNamePrefix = threadNamePrefixOpt.getOrElse("kafka-raft")
  private val logContext = new LogContext(s"[RaftManager id=${config.nodeId}] ")
  this.logIdent = logContext.logPrefix()
Repository: apache/kafka
File: server/src/test/java/org/apache/kafka/server/config/MinInSyncReplicasConfigTest.java (Java)

Code before:
import org.apache.kafka.common.test.api.ClusterConfig;
import org.apache.kafka.common.test.api.ClusterTemplate;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class MinInSyncReplicasConfigTest {

    @ClusterTemplate("generateConfig")
    public void testDefaultKafkaConfig(ClusterInstance cluster) {
        assertEquals(5, cluster.brokers().get(0).logManager().initialDefaultConfig().minInSyncReplicas);
    }

    static List<ClusterConfig> generateConfig() {
        Map<String, String> props = new HashMap<>();
        props.put(ServerLogConfigs.MIN_IN_SYNC_REPLICAS_CONFIG, "5");

        ClusterConfig config = ClusterConfig.defaultBuilder()
                .setServerProperties(props)
                .build();
        return Collections.singletonList(config);
    }
}


Review comment (suggestion):
Maybe we can use `@ClusterDefault` instead.
```
@ClusterTestDefaults(
    serverProperties = {
        @ClusterConfigProperty(key = "min.insync.replicas", value = "5")
    }
)
```

Code after:
/*
 * 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.server.config;

import org.apache.kafka.common.config.TopicConfig;
import org.apache.kafka.common.test.ClusterInstance;
import org.apache.kafka.common.test.api.ClusterConfigProperty;
import org.apache.kafka.common.test.api.ClusterTest;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class MinInSyncReplicasConfigTest {

    @ClusterTest(serverProperties = {
        @ClusterConfigProperty(key = TopicConfig.MIN_IN_SYNC_REPLICAS_CONFIG, value = "5")
    })
    public void testDefaultKafkaConfig(ClusterInstance cluster) {
        assertEquals(5, cluster.brokers().get(0).logManager().initialDefaultConfig().minInSyncReplicas);
    }
}
Repository: apache/kafka
File: server/src/test/java/org/apache/kafka/server/config/MinInSyncReplicasConfigTest.java (Java)

Code before:
import org.apache.kafka.common.test.ClusterInstance;
import org.apache.kafka.common.test.api.ClusterConfig;
import org.apache.kafka.common.test.api.ClusterTemplate;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class MinInSyncReplicasConfigTest {

    @ClusterTemplate("generateConfig")
    public void testDefaultKafkaConfig(ClusterInstance cluster) {
        assertEquals(5, cluster.brokers().get(0).logManager().initialDefaultConfig().minInSyncReplicas);
    }

    static List<ClusterConfig> generateConfig() {
        Map<String, String> props = new HashMap<>();
        props.put(ServerLogConfigs.MIN_IN_SYNC_REPLICAS_CONFIG, "5");

        ClusterConfig config = ClusterConfig.defaultBuilder()
                .setServerProperties(props)
                .build();
        return Collections.singletonList(config);
    }
}


Review comment (suggestion):
```suggestion
        return List.of(config);
```

Code after:
/*
 * 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.server.config;

import org.apache.kafka.common.config.TopicConfig;
import org.apache.kafka.common.test.ClusterInstance;
import org.apache.kafka.common.test.api.ClusterConfigProperty;
import org.apache.kafka.common.test.api.ClusterTest;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class MinInSyncReplicasConfigTest {

    @ClusterTest(serverProperties = {
        @ClusterConfigProperty(key = TopicConfig.MIN_IN_SYNC_REPLICAS_CONFIG, value = "5")
    })
    public void testDefaultKafkaConfig(ClusterInstance cluster) {
        assertEquals(5, cluster.brokers().get(0).logManager().initialDefaultConfig().minInSyncReplicas);
    }
}
Repository: apache/kafka
File: server/src/test/java/org/apache/kafka/server/config/MinInSyncReplicasConfigTest.java (Java)

Code before:
 * limitations under the License.
 */

package org.apache.kafka.server.config;

import org.apache.kafka.common.test.ClusterInstance;
import org.apache.kafka.common.test.api.ClusterConfig;
import org.apache.kafka.common.test.api.ClusterTemplate;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class MinInSyncReplicasConfigTest {

    @ClusterTemplate("generateConfig")
    public void testDefaultKafkaConfig(ClusterInstance cluster) {
        assertEquals(5, cluster.brokers().get(0).logManager().initialDefaultConfig().minInSyncReplicas);
    }

    static List<ClusterConfig> generateConfig() {
        Map<String, String> props = new HashMap<>();
        props.put(ServerLogConfigs.MIN_IN_SYNC_REPLICAS_CONFIG, "5");

        ClusterConfig config = ClusterConfig.defaultBuilder()
                .setServerProperties(props)
                .build();
        return Collections.singletonList(config);
    }
}


Review comment (suggestion):
```suggestion
        Map<String, String> props = Map.of(ServerLogConfigs.MIN_IN_SYNC_REPLICAS_CONFIG, "5");
```

Code after:
/*
 * 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.server.config;

import org.apache.kafka.common.config.TopicConfig;
import org.apache.kafka.common.test.ClusterInstance;
import org.apache.kafka.common.test.api.ClusterConfigProperty;
import org.apache.kafka.common.test.api.ClusterTest;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class MinInSyncReplicasConfigTest {

    @ClusterTest(serverProperties = {
        @ClusterConfigProperty(key = TopicConfig.MIN_IN_SYNC_REPLICAS_CONFIG, value = "5")
    })
    public void testDefaultKafkaConfig(ClusterInstance cluster) {
        assertEquals(5, cluster.brokers().get(0).logManager().initialDefaultConfig().minInSyncReplicas);
    }
}
Repository: apache/kafka
File: server/src/test/java/org/apache/kafka/server/config/MinInSyncReplicasConfigTest.java (Java)

Code before:
 * 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.server.config;

import org.apache.kafka.common.test.ClusterInstance;
import org.apache.kafka.common.test.api.ClusterConfig;
import org.apache.kafka.common.test.api.ClusterTemplate;

import java.util.List;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class MinInSyncReplicasConfigTest {

    @ClusterTemplate("generateConfig")
    public void testDefaultKafkaConfig(ClusterInstance cluster) {
        assertEquals(5, cluster.brokers().get(0).logManager().initialDefaultConfig().minInSyncReplicas);
    }

    static List<ClusterConfig> generateConfig() {
        var props = Map.of(ServerLogConfigs.MIN_IN_SYNC_REPLICAS_CONFIG, "5");
        var config = ClusterConfig.defaultBuilder()
                .setServerProperties(props)
                .build();
        return List.of(config);
    }
}


Review comment (suggestion):
```suggestion
        ClusterConfig config = ClusterConfig.defaultBuilder()
```

Code after:
/*
 * 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.server.config;

import org.apache.kafka.common.config.TopicConfig;
import org.apache.kafka.common.test.ClusterInstance;
import org.apache.kafka.common.test.api.ClusterConfigProperty;
import org.apache.kafka.common.test.api.ClusterTest;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class MinInSyncReplicasConfigTest {

    @ClusterTest(serverProperties = {
        @ClusterConfigProperty(key = TopicConfig.MIN_IN_SYNC_REPLICAS_CONFIG, value = "5")
    })
    public void testDefaultKafkaConfig(ClusterInstance cluster) {
        assertEquals(5, cluster.brokers().get(0).logManager().initialDefaultConfig().minInSyncReplicas);
    }
}
Repository: apache/kafka
File: server/src/test/java/org/apache/kafka/server/config/MinInSyncReplicasConfigTest.java (Java)

Code before:
 * 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.server.config;

import org.apache.kafka.common.test.ClusterInstance;
import org.apache.kafka.common.test.api.ClusterConfig;
import org.apache.kafka.common.test.api.ClusterTemplate;

import java.util.List;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class MinInSyncReplicasConfigTest {

    @ClusterTemplate("generateConfig")
    public void testDefaultKafkaConfig(ClusterInstance cluster) {
        assertEquals(5, cluster.brokers().get(0).logManager().initialDefaultConfig().minInSyncReplicas);
    }

    static List<ClusterConfig> generateConfig() {
        var props = Map.of(ServerLogConfigs.MIN_IN_SYNC_REPLICAS_CONFIG, "5");
        var config = ClusterConfig.defaultBuilder()
                .setServerProperties(props)
                .build();
        return List.of(config);
    }
}


Review comment (suggestion):
I prefer a more explicit way.
```suggestion
        Map<String, String> props = Map.of(ServerLogConfigs.MIN_IN_SYNC_REPLICAS_CONFIG, "5");
```

Code after:
/*
 * 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.server.config;

import org.apache.kafka.common.config.TopicConfig;
import org.apache.kafka.common.test.ClusterInstance;
import org.apache.kafka.common.test.api.ClusterConfigProperty;
import org.apache.kafka.common.test.api.ClusterTest;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class MinInSyncReplicasConfigTest {

    @ClusterTest(serverProperties = {
        @ClusterConfigProperty(key = TopicConfig.MIN_IN_SYNC_REPLICAS_CONFIG, value = "5")
    })
    public void testDefaultKafkaConfig(ClusterInstance cluster) {
        assertEquals(5, cluster.brokers().get(0).logManager().initialDefaultConfig().minInSyncReplicas);
    }
}
Repository: apache/kafka
File: server/src/test/java/org/apache/kafka/server/config/MinInSyncReplicasConfigTest.java (Java)

Code before:
 * (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.server.config;

import org.apache.kafka.common.test.ClusterInstance;
import org.apache.kafka.common.test.api.ClusterConfig;
import org.apache.kafka.common.test.api.ClusterTemplate;

import java.util.List;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class MinInSyncReplicasConfigTest {

    @ClusterTemplate("generateConfig")
    public void testDefaultKafkaConfig(ClusterInstance cluster) {
        assertEquals(5, cluster.brokers().get(0).logManager().initialDefaultConfig().minInSyncReplicas);
    }

    static List<ClusterConfig> generateConfig() {
        var props = Map.of(ServerLogConfigs.MIN_IN_SYNC_REPLICAS_CONFIG, "5");
        var config = ClusterConfig.defaultBuilder()
                .setServerProperties(props)
                .build();
        return List.of(config);
    }
}


Review comment (suggestion):
```suggestion
    @ClusterTest(serverProperties = {
        @ClusterConfigProperty(key = TopicConfig.MIN_IN_SYNC_REPLICAS_CONFIG, value = "5"),
    })
```

Code after:
 * (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.server.config;

import org.apache.kafka.common.config.TopicConfig;
import org.apache.kafka.common.test.ClusterInstance;
import org.apache.kafka.common.test.api.ClusterConfigProperty;
import org.apache.kafka.common.test.api.ClusterTest;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class MinInSyncReplicasConfigTest {

    @ClusterTest(serverProperties = {
        @ClusterConfigProperty(key = TopicConfig.MIN_IN_SYNC_REPLICAS_CONFIG, value = "5")
    })
    public void testDefaultKafkaConfig(ClusterInstance cluster) {
        assertEquals(5, cluster.brokers().get(0).logManager().initialDefaultConfig().minInSyncReplicas);
    }
}