diff --git a/.editorconfig b/.editorconfig
index 036b064..4a9df60 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,8 +1,15 @@
[*.{kt,kts}]
+max_line_length = 120
+
# Comma-separated list of rules to disable (Since 0.34.0)
# 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
+max_line_length = 120
diff --git a/pom.xml b/pom.xml
index 3d58ae3..d840c03 100644
--- a/pom.xml
+++ b/pom.xml
@@ -43,10 +43,13 @@
UTF-8
4.6.0
- 5.8.1
+ 5.10.0
11
- 1.6.21
- 5.3.0
+ 1.9.10
+
+ 1.9.10-dev-234
+ 5.7.2
+ 1.13.8
@@ -115,6 +118,13 @@
${kotest.version}
test
+
+ io.mockk
+ mockk-jvm
+ ${mockk.version}
+ test
+
+
@@ -218,7 +228,7 @@
com.github.gantsign.maven
ktlint-maven-plugin
- 1.13.1
+ 2.0.0
${project.basedir}/src/main/kotlin
@@ -351,7 +361,7 @@
org.jetbrains.dokka
dokka-maven-plugin
- ${kotlin.version}
+ ${dokka.version}
prepare-package
@@ -367,7 +377,7 @@
org.jetbrains.dokka
kotlin-as-java-plugin
- ${kotlin.version}
+ ${dokka.version}
@@ -380,6 +390,22 @@
+
+
+
+ jetbrains-dev
+ Jetbrains development Repository
+
+ true
+
+
+ true
+
+
+ https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev/
+
+
+
coverage
diff --git a/src/main/kotlin/org/jitsi/utils/Delegates.kt b/src/main/kotlin/org/jitsi/utils/Delegates.kt
index 19098d0..8c57d75 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 9ed9143..9ba6f28 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/RangedString.kt b/src/main/kotlin/org/jitsi/utils/RangedString.kt
index 8a74ff0..d79e19d 100644
--- a/src/main/kotlin/org/jitsi/utils/RangedString.kt
+++ b/src/main/kotlin/org/jitsi/utils/RangedString.kt
@@ -94,7 +94,14 @@ fun Iterable.joinToRangedString(
postfix: CharSequence = "",
rangeLimit: Int = -1,
truncated: CharSequence = "..."
-): String = this.iterator().joinToRangedString(separator = separator, rangeSeparator = rangeSeparator, prefix = prefix, postfix = postfix, rangeLimit = rangeLimit, truncated = truncated)
+): String = this.iterator().joinToRangedString(
+ separator = separator,
+ rangeSeparator = rangeSeparator,
+ prefix = prefix,
+ postfix = postfix,
+ rangeLimit = rangeLimit,
+ truncated = truncated
+)
fun Sequence.joinToRangedString(
separator: CharSequence = ", ",
@@ -103,7 +110,14 @@ fun Sequence.joinToRangedString(
postfix: CharSequence = "",
rangeLimit: Int = -1,
truncated: CharSequence = "..."
-): String = this.iterator().joinToRangedString(separator = separator, rangeSeparator = rangeSeparator, prefix = prefix, postfix = postfix, rangeLimit = rangeLimit, truncated = truncated)
+): String = this.iterator().joinToRangedString(
+ separator = separator,
+ rangeSeparator = rangeSeparator,
+ prefix = prefix,
+ postfix = postfix,
+ rangeLimit = rangeLimit,
+ truncated = truncated
+)
fun Array.joinToRangedString(
separator: CharSequence = ", ",
@@ -112,4 +126,11 @@ fun Array.joinToRangedString(
postfix: CharSequence = "",
rangeLimit: Int = -1,
truncated: CharSequence = "..."
-): String = this.iterator().joinToRangedString(separator = separator, rangeSeparator = rangeSeparator, prefix = prefix, postfix = postfix, rangeLimit = rangeLimit, truncated = truncated)
+): String = this.iterator().joinToRangedString(
+ separator = separator,
+ rangeSeparator = rangeSeparator,
+ prefix = prefix,
+ postfix = postfix,
+ rangeLimit = rangeLimit,
+ truncated = truncated
+)
diff --git a/src/main/kotlin/org/jitsi/utils/queue/QueueStatistics.kt b/src/main/kotlin/org/jitsi/utils/queue/QueueStatistics.kt
index a1be15e..1229632 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?
}
}
@@ -127,7 +127,11 @@ class QueueStatistics(queueSize: Int, val clock: Clock) {
QueueStatistics(queue.capacity(), clock)
}
- fun getStatistics() = OrderedJsonObject().apply { queueStatsById.entries.forEach { put(it.key, it.value.stats) } }
+ fun getStatistics() = OrderedJsonObject().apply {
+ queueStatsById.entries.forEach {
+ put(it.key, it.value.stats)
+ }
+ }
/**
* Calculate the capacity statistics buckets for a given queue capacity.
@@ -175,7 +179,11 @@ class QueueStatisticsObserver(
/**
* A map of the time when objects were put in the queue
*/
- private val insertionTime = if (QueueStatistics.TRACK_TIMES) Collections.synchronizedMap(IdentityHashMap()) else null
+ private val insertionTime = if (QueueStatistics.TRACK_TIMES) {
+ Collections.synchronizedMap(IdentityHashMap())
+ } else {
+ null
+ }
private val localStats = if (QueueStatistics.DEBUG) QueueStatistics(queue.capacity(), clock) else null
private val globalStats = QueueStatistics.globalStatsFor(queue, clock)
@@ -212,7 +220,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 c09c6bd..83d8200 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 2237604..07a83c7 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 2b2d545..bc0a7f4 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 9b0eb41..f79738b 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