Revert "Implement post reply provider interface in Core."
[Sone.git] / src / main / java / net / pterodactylus / sone / core / Core.java
index 37c026f..b25d8e3 100644 (file)
@@ -59,6 +59,7 @@ import net.pterodactylus.util.config.ConfigurationException;
 import net.pterodactylus.util.logging.Logging;
 import net.pterodactylus.util.number.Numbers;
 import net.pterodactylus.util.service.AbstractService;
+import net.pterodactylus.util.thread.NamedThreadFactory;
 import net.pterodactylus.util.thread.Ticker;
 import net.pterodactylus.util.validation.EqualityValidator;
 import net.pterodactylus.util.validation.IntegerRangeValidator;
@@ -108,7 +109,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
        private final ImageInserter imageInserter;
 
        /** Sone downloader thread-pool. */
-       private final ExecutorService soneDownloaders = Executors.newFixedThreadPool(10);
+       private final ExecutorService soneDownloaders = Executors.newFixedThreadPool(10, new NamedThreadFactory("Sone Downloader %2$d"));
 
        /** The update checker. */
        private final UpdateChecker updateChecker;
@@ -608,18 +609,6 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
 
        /**
         * Returns the reply with the given ID. If there is no reply with the given
-        * ID yet, a new one is created.
-        *
-        * @param replyId
-        *            The ID of the reply to get
-        * @return The reply
-        */
-       public PostReply getReply(String replyId) {
-               return getReply(replyId, true);
-       }
-
-       /**
-        * Returns the reply with the given ID. If there is no reply with the given
         * ID yet, a new one is created, unless {@code create} is false in which
         * case {@code null} is returned.
         *
@@ -630,7 +619,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
         *            to return {@code null} if no reply can be found
         * @return The reply, or {@code null} if there is no such reply
         */
-       public PostReply getReply(String replyId, boolean create) {
+       public PostReply getPostReply(String replyId, boolean create) {
                synchronized (replies) {
                        PostReply reply = replies.get(replyId);
                        if (create && (reply == null)) {
@@ -1381,7 +1370,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
                                logger.log(Level.WARNING, "Invalid reply found, aborting load!");
                                return;
                        }
-                       replies.add(getReply(replyId).setSone(sone).setPost(getPost(postId)).setTime(replyTime).setText(replyText));
+                       replies.add(getPostReply(replyId, true).setSone(sone).setPost(getPost(postId)).setTime(replyTime).setText(replyText));
                }
 
                /* load post likes. */
@@ -2414,7 +2403,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
         */
        @Override
        public void identityUpdated(OwnIdentity ownIdentity, final Identity identity) {
-               new Thread(new Runnable() {
+               soneDownloaders.execute(new Runnable() {
 
                        @Override
                        @SuppressWarnings("synthetic-access")
@@ -2425,7 +2414,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
                                soneDownloader.addSone(sone);
                                soneDownloader.fetchSone(sone);
                        }
-               }).start();
+               });
        }
 
        /**