diff --git a/source/de/anomic/http/httpClient.java b/source/de/anomic/http/httpClient.java index 14b9c8322..a869c393f 100644 --- a/source/de/anomic/http/httpClient.java +++ b/source/de/anomic/http/httpClient.java @@ -220,8 +220,11 @@ public class httpClient { * (non-Javadoc) * @see de.anomic.http.HttpClient#setTimeout(int) */ - public void setTimeout(final int timeout) { + @SuppressWarnings("deprecation") + public void setTimeout(final int timeout) { apacheHttpClient.getParams().setIntParameter(HttpMethodParams.SO_TIMEOUT, timeout); + apacheHttpClient.getParams().setIntParameter(HttpMethodParams.HEAD_BODY_CHECK_TIMEOUT, timeout); + apacheHttpClient.setConnectionTimeout(timeout); } /** diff --git a/source/de/anomic/kelondro/index/IndexTest.java b/source/de/anomic/kelondro/index/IndexTest.java index d9a17f387..c9a18f73c 100644 --- a/source/de/anomic/kelondro/index/IndexTest.java +++ b/source/de/anomic/kelondro/index/IndexTest.java @@ -103,7 +103,7 @@ public class IndexTest { hm.clear(); hm = null; long t5 = System.currentTimeMillis(); System.out.println("time for HashMap test: " + (t5 - t4) + ", " + bugs + " bugs"); - System.out.println("memory for HashMap: " + (freeStartHash - freeEndHash) / mb + " MB\n"); + System.out.println("memory for HashMap: " + (freeStartHash - freeEndHash) / mb + " MB\n"); // test kelondro index Runtime.getRuntime().gc(); diff --git a/source/de/anomic/kelondro/order/Digest.java b/source/de/anomic/kelondro/order/Digest.java index daf7436ea..4f9407dc9 100644 --- a/source/de/anomic/kelondro/order/Digest.java +++ b/source/de/anomic/kelondro/order/Digest.java @@ -46,7 +46,19 @@ import java.util.concurrent.LinkedBlockingQueue; public class Digest { - + + public static BlockingQueue digestPool = new ArrayBlockingQueue(10); + static { + for (int i = 0; i < 10; i++) + try { + MessageDigest digest = MessageDigest.getInstance("MD5"); + digest.reset(); + digestPool.add(digest); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + } + public static String encodeHex(final long in, final int length) { String s = Long.toHexString(in); while (s.length() < length) s = "0" + s; @@ -98,8 +110,7 @@ public class Digest { public static byte[] encodeMD5Raw(final String key) { try { - final MessageDigest digest = MessageDigest.getInstance("MD5"); - digest.reset(); + final MessageDigest digest = digestPool.take(); byte[] keyBytes; try { keyBytes = key.getBytes("UTF-8"); @@ -107,10 +118,13 @@ public class Digest { keyBytes = key.getBytes(); } digest.update(keyBytes); - return digest.digest(); - } catch (final java.security.NoSuchAlgorithmException e) { - System.out.println("Internal Error at md5:" + e.getMessage()); - } + byte[] result = digest.digest(); + digest.reset(); + digestPool.put(digest); + return result; + } catch (InterruptedException e) { + System.out.println("Internal Error at md5:" + e.getMessage()); + } return null; } diff --git a/source/de/anomic/plasma/parser/Word.java b/source/de/anomic/plasma/parser/Word.java index 221b1833d..fb2425374 100644 --- a/source/de/anomic/plasma/parser/Word.java +++ b/source/de/anomic/plasma/parser/Word.java @@ -86,7 +86,6 @@ public class Word { if (h != null) return h; h = Base64Order.enhancedCoder.encodeSubstring(Digest.encodeMD5Raw(word.toLowerCase(Locale.ENGLISH)), yacySeedDB.commonHashLength); assert h[2] != '@'; - String s = new String(h); hashCache.put(word, h); // prevent expensive MD5 computation and encoding return h; }