Merge remote-tracking branch 'beak/next' into next
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 21 Dec 2012 06:30:45 +0000 (07:30 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 21 Dec 2012 06:30:45 +0000 (07:30 +0100)
1  2 
src/main/java/net/pterodactylus/sone/core/Core.java

@@@ -59,6 -59,7 +59,7 @@@ import net.pterodactylus.util.config.Co
  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 +109,7 @@@ public class Core extends AbstractServi
        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;
         * @return The created post
         */
        public Post createPost(Sone sone, Sone recipient, long time, String text) {
 +              Validation.begin().isNotNull("Text", text).check().isGreater("Text Length", text.length(), 0).check();
                if (!isLocalSone(sone)) {
                        logger.log(Level.FINE, String.format("Tried to create post for non-local Sone: %s", sone));
                        return null;
         * @return The created reply
         */
        public PostReply createReply(Sone sone, Post post, long time, String text) {
 +              Validation.begin().isNotNull("Text", text).check().isGreater("Text Length", text.trim().length(), 0).check();
                if (!isLocalSone(sone)) {
                        logger.log(Level.FINE, String.format("Tried to create reply for non-local Sone: %s", sone));
                        return null;
         */
        @Override
        public void identityUpdated(OwnIdentity ownIdentity, final Identity identity) {
-               new Thread(new Runnable() {
+               soneDownloaders.execute(new Runnable() {
  
                        @Override
                        @SuppressWarnings("synthetic-access")
                                soneDownloader.addSone(sone);
                                soneDownloader.fetchSone(sone);
                        }
-               }).start();
+               });
        }
  
        /**