From a7dcf848a480ab879b25976c79e4f46b65022949 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 16 Oct 2010 12:00:38 +0200 Subject: [PATCH] Always download Sones in an own thread. --- .../java/net/pterodactylus/sone/core/Core.java | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 94d1169..6225087 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -308,17 +308,24 @@ public class Core extends AbstractService { * @param requestUri * The request URI to load the Sone from */ - public void loadSone(String requestUri) { - try { - FreenetURI realRequestUri = new FreenetURI(requestUri).setMetaString(new String[] { "sone.xml" }); - FetchResult fetchResult = freenetInterface.fetchUri(realRequestUri); - Sone parsedSone = soneDownloader.parseSone(null, fetchResult, realRequestUri); - if (parsedSone != null) { - addSone(parsedSone); + public void loadSone(final String requestUri) { + new Thread(new Runnable() { + + @Override + @SuppressWarnings("synthetic-access") + public void run() { + try { + FreenetURI realRequestUri = new FreenetURI(requestUri).setMetaString(new String[] { "sone.xml" }); + FetchResult fetchResult = freenetInterface.fetchUri(realRequestUri); + Sone parsedSone = soneDownloader.parseSone(null, fetchResult, realRequestUri); + if (parsedSone != null) { + addSone(parsedSone); + } + } catch (MalformedURLException mue1) { + logger.log(Level.INFO, "Could not create URI from “" + requestUri + "”.", mue1); + } } - } catch (MalformedURLException mue1) { - logger.log(Level.INFO, "Could not create URI from “" + requestUri + "”.", mue1); - } + }, "Sone Downloader").start(); } /** -- 2.7.4