jsancio commented on a change in pull request #9816: URL: https://github.com/apache/kafka/pull/9816#discussion_r557643648
########## File path: core/src/main/scala/kafka/raft/KafkaMetadataLog.scala ########## @@ -29,15 +32,22 @@ import org.apache.kafka.snapshot.FileRawSnapshotReader import org.apache.kafka.snapshot.FileRawSnapshotWriter import org.apache.kafka.snapshot.RawSnapshotReader import org.apache.kafka.snapshot.RawSnapshotWriter +import org.apache.kafka.snapshot.Snapshots import scala.compat.java8.OptionConverters._ -class KafkaMetadataLog( +final class KafkaMetadataLog private ( log: Log, + snapshotIds: ConcurrentSkipListSet[raft.OffsetAndEpoch], topicPartition: TopicPartition, - maxFetchSizeInBytes: Int = 1024 * 1024 + maxFetchSizeInBytes: Int ) extends ReplicatedLog { + private[this] var startSnapshotId = snapshotIds Review comment: Scala generates different code for `private[this]` vs `private` when used on a field. Scala visibility model is different from the JVM visibility model. Because of this when using `private` on a field, Scala generates access methods for the field. When using `private[this]` Scala doesn't generate these access methods. For example: ```scala final class PrivateThisTest { private[this] var privateThis = Some(10); private var justPrivate = Some(20); } ``` generates (`javap -p ...`) the following class: ```java public final class PrivateThisTest { private scala.Some<java.lang.Object> privateThis; private scala.Some<java.lang.Object> justPrivate; private scala.Some<java.lang.Object> justPrivate(); private void justPrivate_$eq(scala.Some<java.lang.Object>); public PrivateThisTest(); } ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org