diff --git a/build.gradle b/build.gradle index f9a4975..09ef1fb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,9 @@ group 'io.kweb' -version '0.2.18' +version '0.2.19' buildscript { - ext.kotlin_version = '1.2.50' - ext.dokka_version = '0.9.15' + ext.kotlin_version = '1.2.51' + ext.dokka_version = '0.9.17' repositories { jcenter() @@ -21,15 +21,17 @@ buildscript { } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.1.10' + classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.3.0' classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" - + classpath 'com.github.ben-manes:gradle-versions-plugin:0.20.0' } + } apply plugin: 'kotlin' apply plugin: 'org.jetbrains.dokka' apply plugin: "info.solidsoft.pitest" +apply plugin: "com.github.ben-manes.versions" repositories { mavenCentral() @@ -45,12 +47,12 @@ repositories { dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" - compile 'com.github.salomonbrys.kotson:kotson:2.3.0' - compile 'com.google.guava:guava:18.0' + compile 'com.github.salomonbrys.kotson:kotson:2.5.0' + compile 'com.google.guava:guava:25.1-jre' compile 'net.incongru.watchservice:barbary-watchservice:1.0' compile 'com.fatboyindustrial.gson-javatime-serialisers:gson-javatime-serialisers:1.1.1' - testCompile 'io.kotlintest:kotlintest:2.0.1' + testCompile 'io.kotlintest:kotlintest:2.0.7' } task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) { diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 8ac176e..0d4a951 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0afbfe4..a95009c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Sat Jun 10 08:59:19 CDT 2017 -distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-bin.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 4453cce..cccdd3d 100755 --- a/gradlew +++ b/gradlew @@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS="" # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -155,7 +155,7 @@ if $cygwin ; then fi # Escape application args -save ( ) { +save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } diff --git a/src/main/kotlin/io/kweb/shoebox/stores/DirectoryStore.kt b/src/main/kotlin/io/kweb/shoebox/stores/DirectoryStore.kt index 8815f2c..f6086cb 100644 --- a/src/main/kotlin/io/kweb/shoebox/stores/DirectoryStore.kt +++ b/src/main/kotlin/io/kweb/shoebox/stores/DirectoryStore.kt @@ -22,9 +22,9 @@ inline fun DirectoryStore(directory : Path) = DirectoryStore(d class DirectoryStore(val directory : Path, private val kc : KClass) : Store { companion object { - const private val LOCK_FILENAME = "shoebox.lock" - const private val LOCK_TOUCH_TIME_MS = 100.toLong() - const private val LOCK_STALE_TIME = LOCK_TOUCH_TIME_MS * 2 + private const val LOCK_FILENAME = "shoebox.lock" + private val LOCK_TOUCH_TIME = Duration.ofMillis(100) + private val LOCK_STALE_TIME = LOCK_TOUCH_TIME.multipliedBy(20) private val gson = Converters.registerAll(GsonBuilder()).let { it.registerTypeAdapter(object : TypeToken() {}.type, DurationConverter()) }.create() @@ -56,7 +56,8 @@ class DirectoryStore(val directory : Path, private val kc : KClass) init { Files.createDirectories(directory) if (Files.exists(lockFilePath)) { - if (System.currentTimeMillis() - Files.getLastModifiedTime(lockFilePath).toMillis() < LOCK_STALE_TIME) { + val durationSinceLock = Duration.between(Files.getLastModifiedTime(lockFilePath).toInstant(), Instant.now()) + if (durationSinceLock < LOCK_STALE_TIME) { throw RuntimeException("$directory locked by $lockFilePath, created ${System.currentTimeMillis() - Files.getLastModifiedTime(lockFilePath).toMillis()}ms ago.") } else { Files.setLastModifiedTime(lockFilePath, FileTime.fromMillis(System.currentTimeMillis())) @@ -68,7 +69,7 @@ class DirectoryStore(val directory : Path, private val kc : KClass) } scheduledExecutor.scheduleWithFixedDelay({ Files.setLastModifiedTime(lockFilePath, FileTime.fromMillis(System.currentTimeMillis())) - }, LOCK_TOUCH_TIME_MS, LOCK_TOUCH_TIME_MS, TimeUnit.MILLISECONDS) + }, LOCK_TOUCH_TIME.toMillis(), LOCK_TOUCH_TIME.toMillis(), TimeUnit.MILLISECONDS) } /** diff --git a/src/test/kotlin/io/kweb/shoebox/stores/DirectoryStoreSpec.kt b/src/test/kotlin/io/kweb/shoebox/stores/DirectoryStoreSpec.kt index 73682e6..97595cd 100644 --- a/src/test/kotlin/io/kweb/shoebox/stores/DirectoryStoreSpec.kt +++ b/src/test/kotlin/io/kweb/shoebox/stores/DirectoryStoreSpec.kt @@ -1,11 +1,8 @@ package io.kweb.shoebox.stores -import io.kweb.shoebox.ShoeboxSpec -import io.kotlintest.matchers.gt -import io.kotlintest.matchers.shouldBe -import io.kotlintest.matchers.shouldEqual -import io.kotlintest.matchers.shouldThrow +import io.kotlintest.matchers.* import io.kotlintest.specs.FreeSpec +import io.kweb.shoebox.ShoeboxSpec import io.kweb.shoebox.ShoeboxSpec.TestData import java.nio.file.Files import java.nio.file.attribute.FileTime @@ -56,7 +53,7 @@ class DirectoryStoreSpec : FreeSpec() { val pm = DirectoryStore(dir) pm["key1"] = object1 "should cache the item that was stored" { - pm.cache.get("key1") shouldEqual object1 + pm.cache.get("key1").value shouldEqual object1 } } "when an item is replaced" - { @@ -66,7 +63,7 @@ class DirectoryStoreSpec : FreeSpec() { pm["key1"] = object2 "should have cached the replaced data" { - pm.cache.get("key1") shouldEqual object2 + pm.cache.get("key1").value shouldEqual object2 } "should retrieve the replaced data without the cache" { pm.cache.invalidate("key1")