diff --git a/src/main/kotlin/org/unbrokendome/gradle/plugins/helm/util/DigestUtils.kt b/src/main/kotlin/org/unbrokendome/gradle/plugins/helm/util/DigestUtils.kt index 96d7a737..f10e852e 100644 --- a/src/main/kotlin/org/unbrokendome/gradle/plugins/helm/util/DigestUtils.kt +++ b/src/main/kotlin/org/unbrokendome/gradle/plugins/helm/util/DigestUtils.kt @@ -29,7 +29,7 @@ internal fun calculateDigest( while (true) { - buffer.clear() + buffer.safeClear() val bytesRead = channel.read(buffer) if (bytesRead == -1) { @@ -44,6 +44,16 @@ internal fun calculateDigest( } +/** + * Avoid using ByteBuffer.clear because of a JDK incompatibility that might lead to a NoSuchMethodError + * when compiling with JDK > 8 and running with JDK 8. + */ +private fun ByteBuffer.safeClear() { + position(0) + limit(capacity()) +} + + /** * Calculates a digest over the contents of a file. *