xmvn/0001-Don-t-use-JAXB-for-converting-bytes-to-hex-string.patch

59 lines
2.0 KiB
Diff

From 336cbdc97f3c7055ebdf858141bfc160fd4d412b Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Fri, 8 Dec 2017 18:00:54 +0100
Subject: [PATCH] Don't use JAXB for converting bytes to hex string
---
.../java/org/fedoraproject/xmvn/resolver/impl/CacheManager.java | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/CacheManager.java b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/CacheManager.java
index 1d6c193b..0902aa88 100644
--- a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/CacheManager.java
+++ b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/CacheManager.java
@@ -16,14 +16,13 @@
package org.fedoraproject.xmvn.resolver.impl;
import java.io.IOException;
+import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
-
/**
* @author Mikolaj Izdebski
*/
@@ -31,8 +30,6 @@ class CacheManager
{
private static final String DIGEST_ALGORITHM = "SHA-1";
- private final HexBinaryAdapter hexAdapter;
-
private final MessageDigest digest;
private static volatile Path cacheHome;
@@ -41,7 +38,6 @@ class CacheManager
{
try
{
- hexAdapter = new HexBinaryAdapter();
digest = MessageDigest.getInstance( DIGEST_ALGORITHM );
}
catch ( NoSuchAlgorithmException e )
@@ -53,7 +49,7 @@ class CacheManager
private String hash( Path path )
throws IOException
{
- return hexAdapter.marshal( digest.digest( Files.readAllBytes( path ) ) );
+ return new BigInteger( 1, digest.digest( Files.readAllBytes( path ) ) ).setBit( 160 ).toString( 16 ).substring( 1 ).toUpperCase();
}
private static Path getPathDefault( String key, Object defaultValue )
--
2.14.3