Skip to content

Commit

Permalink
Update Kotlin to 1.9.10, and related Maven packages.
Browse files Browse the repository at this point in the history
Apply ktlint fixes from ktlint 0.50.0.
  • Loading branch information
JonathanLennox committed Sep 26, 2023
1 parent 02b0c86 commit f5f97bc
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 13 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 14 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spotbugs.version>4.6.0</spotbugs.version>
<org.junit.version>5.8.1</org.junit.version>
<org.junit.version>5.10.0</org.junit.version>
<java.version>11</java.version>
<kotlin.version>1.6.21</kotlin.version>
<kotest.version>5.3.0</kotest.version>
<kotlin.version>1.9.10</kotlin.version>
<dokka.version>1.9.0</dokka.version>
<kotest.version>5.7.2</kotest.version>
<mockk.version>1.13.8</mockk.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -115,6 +117,12 @@
<version>${kotest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.mockk</groupId>
<artifactId>mockk-jvm</artifactId>
<version>${mockk.version}</version>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -218,7 +226,7 @@
<plugin>
<groupId>com.github.gantsign.maven</groupId>
<artifactId>ktlint-maven-plugin</artifactId>
<version>1.13.1</version>
<version>2.0.0</version>
<configuration>
<sourceRoots>
<sourceRoot>${project.basedir}/src/main/kotlin</sourceRoot>
Expand Down Expand Up @@ -351,7 +359,7 @@
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<version>${dokka.version}</version>
<executions>
<execution>
<phase>prepare-package</phase>
Expand All @@ -367,7 +375,7 @@
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>kotlin-as-java-plugin</artifactId>
<version>${kotlin.version}</version>
<version>${dokka.version}</version>
</plugin>
</dokkaPlugins>
</configuration>
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/org/jitsi/utils/Delegates.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ inline fun <T> 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.
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/org/jitsi/utils/JavaVersion.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

@file:JvmName("JavaVersion")

package org.jitsi.utils

fun getJavaVersion(): Int {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/jitsi/utils/queue/QueueStatistics.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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?
}
}

Expand Down Expand Up @@ -212,7 +212,7 @@ class QueueStatisticsObserver<T>(
*/
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()
Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/org/jitsi/utils/stats/BucketStats.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/kotlin/org/jitsi/utils/stats/RateTracker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ open class RateTracker @JvmOverloads constructor(
)
}
}

/**
* Total count recorded in buckets.
*/
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/org/jitsi/utils/time/FakeClock.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ class FakeClock(
}

override fun withZone(zone: ZoneId?): Clock {
if (zone_ == zone)
if (zone_ == zone) {
return this
}
return FakeClock(zone_ = zone!!)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class FakeScheduledExecutorServiceTest : ShouldSpec() {
{
numJobRuns++
},
5, 5, TimeUnit.SECONDS
5,
5,
TimeUnit.SECONDS
)
context("and then calling runOne") {
executor.runOne()
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f5f97bc

Please sign in to comment.