Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion base/src/main/java/proguard/UpToDateChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ public void updateInputModificationTime(URL url)
{
updateModificationTime(new File(url.toURI()), false);
}
catch (URISyntaxException ignore) {}
catch (URISyntaxException exception)
{
// The input couldn't be checked, so conservatively consider the output outdated.
throw new IllegalStateException("Can't check the input modification time", exception);
}
}
}

Expand Down
37 changes: 37 additions & 0 deletions base/src/test/kotlin/proguard/UpToDateCheckerTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package proguard

import io.kotest.assertions.throwables.shouldNotThrowAny
import io.kotest.core.spec.style.FreeSpec
import java.io.File
import java.net.URL
import java.nio.file.Files

class UpToDateCheckerTest : FreeSpec({
"An invalid file URI does not hide an outdated obfuscation dictionary" {
val directory = Files.createTempDirectory("proguard-up-to-date-test").toFile()

try {
val output = File(directory, "output.jar").apply {
createNewFile()
setLastModified(1_000L)
}
val dictionary = File(directory, "dictionary with spaces.txt").apply {
createNewFile()
setLastModified(2_000L)
}

val configuration = Configuration().apply {
programJars = ClassPath().apply {
add(ClassPathEntry(output, true))
}
obfuscationDictionary = URL(dictionary.toURI().toString().replace("%20", " "))

Check warning on line 27 in base/src/test/kotlin/proguard/UpToDateCheckerTest.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Deprecated code should not be used.

See more on https://sonarcloud.io/project/issues?id=Guardsquare_proguard&issues=AaDTJw6OBMPmUmQM-xOU&open=AaDTJw6OBMPmUmQM-xOU&pullRequest=539
}

shouldNotThrowAny {
UpToDateChecker(configuration).check()
}
} finally {
directory.deleteRecursively()
}
}
})