From f5f97bc4fd82f12b1ccebf738c519bf1774d4cc0 Mon Sep 17 00:00:00 2001 From: Jonathan Lennox Date: Tue, 26 Sep 2023 16:27:53 -0400 Subject: [PATCH] Update Kotlin to 1.9.10, and related Maven packages. Apply ktlint fixes from ktlint 0.50.0. --- .editorconfig | 4 ++++ pom.xml | 20 +++++++++++++------ src/main/kotlin/org/jitsi/utils/Delegates.kt | 1 + .../kotlin/org/jitsi/utils/JavaVersion.kt | 1 + .../org/jitsi/utils/queue/QueueStatistics.kt | 4 ++-- .../org/jitsi/utils/stats/BucketStats.kt | 4 ++++ .../org/jitsi/utils/stats/RateTracker.kt | 5 ++++- .../kotlin/org/jitsi/utils/time/FakeClock.kt | 3 ++- .../FakeScheduledExecutorServiceTest.kt | 12 ++++++++--- 9 files changed, 41 insertions(+), 13 deletions(-) diff --git a/.editorconfig b/.editorconfig index 036b064d..d1d66d40 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,6 +3,10 @@ # Note that rules in any ruleset other than the standard ruleset will need to be prefixed # by the ruleset identifier. +# I find trailing commas annoying +ktlint_standard_trailing-comma-on-call-site = disabled +ktlint_standard_trailing-comma-on-declaration-site = disabled + [pom.xml] indent_style = space indent_size = 4 diff --git a/pom.xml b/pom.xml index 3d58ae3c..931dcd71 100644 --- a/pom.xml +++ b/pom.xml @@ -43,10 +43,12 @@ UTF-8 4.6.0 - 5.8.1 + 5.10.0 11 - 1.6.21 - 5.3.0 + 1.9.10 + 1.9.0 + 5.7.2 + 1.13.8 @@ -115,6 +117,12 @@ ${kotest.version} test + + io.mockk + mockk-jvm + ${mockk.version} + + @@ -218,7 +226,7 @@ com.github.gantsign.maven ktlint-maven-plugin - 1.13.1 + 2.0.0 ${project.basedir}/src/main/kotlin @@ -351,7 +359,7 @@ org.jetbrains.dokka dokka-maven-plugin - ${kotlin.version} + ${dokka.version} prepare-package @@ -367,7 +375,7 @@ org.jetbrains.dokka kotlin-as-java-plugin - ${kotlin.version} + ${dokka.version} diff --git a/src/main/kotlin/org/jitsi/utils/Delegates.kt b/src/main/kotlin/org/jitsi/utils/Delegates.kt index 19098d0d..8c57d755 100644 --- a/src/main/kotlin/org/jitsi/utils/Delegates.kt +++ b/src/main/kotlin/org/jitsi/utils/Delegates.kt @@ -29,6 +29,7 @@ inline fun observableWhenChanged( Delegates.observable(initialValue) { property, oldValue, newValue -> if (oldValue != newValue) onChange(property, oldValue, newValue) } + /** * A delegate which runs a callback (with no arguments) whenever the setter is called and it results in the value * changing. diff --git a/src/main/kotlin/org/jitsi/utils/JavaVersion.kt b/src/main/kotlin/org/jitsi/utils/JavaVersion.kt index 9ed9143e..9ba6f286 100644 --- a/src/main/kotlin/org/jitsi/utils/JavaVersion.kt +++ b/src/main/kotlin/org/jitsi/utils/JavaVersion.kt @@ -15,6 +15,7 @@ */ @file:JvmName("JavaVersion") + package org.jitsi.utils fun getJavaVersion(): Int { diff --git a/src/main/kotlin/org/jitsi/utils/queue/QueueStatistics.kt b/src/main/kotlin/org/jitsi/utils/queue/QueueStatistics.kt index a1be15ec..49d99ccf 100644 --- a/src/main/kotlin/org/jitsi/utils/queue/QueueStatistics.kt +++ b/src/main/kotlin/org/jitsi/utils/queue/QueueStatistics.kt @@ -98,7 +98,7 @@ class QueueStatistics(queueSize: Int, val clock: Clock) { totalPacketsRemoved.increment() queueLengthStats.addValue(queueSize.toLong()) if (waitTime != null) { - queueWaitStats?.addValue(waitTime.toMillis()) /* TODO: measure in nanos? */ + queueWaitStats?.addValue(waitTime.toMillis()) // TODO: measure in nanos? } } @@ -212,7 +212,7 @@ class QueueStatisticsObserver( */ override fun dropped(pkt: T) { queueSize.decrementAndGet() - insertionTime?.remove(pkt) /* TODO: track this time in stats? */ + insertionTime?.remove(pkt) // TODO: track this time in stats? localStats?.dropped() globalStats.dropped() diff --git a/src/main/kotlin/org/jitsi/utils/stats/BucketStats.kt b/src/main/kotlin/org/jitsi/utils/stats/BucketStats.kt index c09c6bd3..83d8200e 100644 --- a/src/main/kotlin/org/jitsi/utils/stats/BucketStats.kt +++ b/src/main/kotlin/org/jitsi/utils/stats/BucketStats.kt @@ -48,8 +48,10 @@ open class BucketStats( private val totalCount = LongAdder() private val average: Double get() = totalValue.sum() / totalCount.sum().toDouble() + /** The maximum value that has been added. */ private val maxValue = AtomicLong(0) + /** The minimum value that has been added. */ private val minValue = AtomicLong(0) private val buckets = Buckets(thresholds) @@ -137,8 +139,10 @@ open class BucketStats( enum class Format { /** Include individual buckets, e.g. [min, 0), [0, 10), [10, 20), [20, max] */ Separate, + /** Combine buckets summing from the left, e.g. [min, 0), [min, 10), [min, 20) */ CumulativeLeft, + /** Combine buckets summing from the right, e.g. [0, max], [10, max], [20, max] */ CumulativeRight } diff --git a/src/main/kotlin/org/jitsi/utils/stats/RateTracker.kt b/src/main/kotlin/org/jitsi/utils/stats/RateTracker.kt index 22376049..07a83c7a 100644 --- a/src/main/kotlin/org/jitsi/utils/stats/RateTracker.kt +++ b/src/main/kotlin/org/jitsi/utils/stats/RateTracker.kt @@ -61,6 +61,7 @@ open class RateTracker @JvmOverloads constructor( ) } } + /** * Total count recorded in buckets. */ @@ -157,8 +158,10 @@ open class RateTracker @JvmOverloads constructor( @JvmOverloads fun update(count: Long = 1, nowMs: Long = clock.millis()) { val now = coerceMs(nowMs) - if (now < oldestTime) // Too old data is ignored. + if (now < oldestTime) { + // Too old data is ignored. return + } if (firstInsertTimeMs < 0) firstInsertTimeMs = nowMs eraseOld(now) val nowOffset = (now - oldestTime).toInt() diff --git a/src/main/kotlin/org/jitsi/utils/time/FakeClock.kt b/src/main/kotlin/org/jitsi/utils/time/FakeClock.kt index 2b2d545a..bc0a7f44 100644 --- a/src/main/kotlin/org/jitsi/utils/time/FakeClock.kt +++ b/src/main/kotlin/org/jitsi/utils/time/FakeClock.kt @@ -55,8 +55,9 @@ class FakeClock( } override fun withZone(zone: ZoneId?): Clock { - if (zone_ == zone) + if (zone_ == zone) { return this + } return FakeClock(zone_ = zone!!) } } diff --git a/src/test/kotlin/org/jitsi/utils/concurrent/FakeScheduledExecutorServiceTest.kt b/src/test/kotlin/org/jitsi/utils/concurrent/FakeScheduledExecutorServiceTest.kt index 9b0eb41e..f79738b9 100644 --- a/src/test/kotlin/org/jitsi/utils/concurrent/FakeScheduledExecutorServiceTest.kt +++ b/src/test/kotlin/org/jitsi/utils/concurrent/FakeScheduledExecutorServiceTest.kt @@ -34,7 +34,9 @@ class FakeScheduledExecutorServiceTest : ShouldSpec() { { numJobRuns++ }, - 5, 5, TimeUnit.SECONDS + 5, + 5, + TimeUnit.SECONDS ) context("and then calling runOne") { executor.runOne() @@ -87,7 +89,9 @@ class FakeScheduledExecutorServiceTest : ShouldSpec() { // Elapse time inside the job to simulate a long job executor.clock.elapse(3.secs) }, - 5, 5, TimeUnit.SECONDS + 5, + 5, + TimeUnit.SECONDS ) should("run the job at a fixed rate") { // Run the first job @@ -107,7 +111,9 @@ class FakeScheduledExecutorServiceTest : ShouldSpec() { // Elapse time inside the job to simulate a long job executor.clock.elapse(3.secs) }, - 5, 5, TimeUnit.SECONDS + 5, + 5, + TimeUnit.SECONDS ) should("run the job with a fixed rate") { // Run the first job