diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/LfsBlobStoreCleanFilter.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/LfsBlobStoreCleanFilter.java index 7c9c3d3225..bb54ea162a 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/LfsBlobStoreCleanFilter.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/LfsBlobStoreCleanFilter.java @@ -4,6 +4,7 @@ import com.google.common.io.ByteStreams; import org.eclipse.jgit.attributes.FilterCommand; import org.eclipse.jgit.lfs.LfsPointer; import org.eclipse.jgit.lfs.lib.AnyLongObjectId; +import org.eclipse.jgit.lfs.lib.Constants; import org.eclipse.jgit.lfs.lib.LongObjectId; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -17,10 +18,6 @@ import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Path; import java.security.DigestOutputStream; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import static org.eclipse.jgit.lfs.lib.Constants.LONG_HASH_FUNCTION; /** * Adapted version of JGit's {@link org.eclipse.jgit.lfs.CleanFilter} to write the @@ -75,21 +72,12 @@ class LfsBlobStoreCleanFilter extends FilterCommand { } } - // Suppress warning for RuntimeException after check for wrong size, because hash alg for sha256 is built in - @SuppressWarnings("squid:S00112") private DigestOutputStream createDigestStream() { - MessageDigest md ; - try { - md = MessageDigest.getInstance(LONG_HASH_FUNCTION); - } catch (NoSuchAlgorithmException e) { - // Yes there is such a hash function (should be sha256) - throw new RuntimeException(e); - } return new DigestOutputStream(new OutputStream() { @Override public void write(int b) { // no further target here, we are just interested in the digest } - }, md); + }, Constants.newMessageDigest()); } }