Access source threadsafely.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 16 Mar 2013 17:46:29 +0000 (18:46 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 16 Mar 2013 17:46:29 +0000 (18:46 +0100)
src/main/java/net/pterodactylus/sonitus/data/filter/MultiSourceFilter.java

index 57c313e..38e7473 100644 (file)
@@ -135,9 +135,11 @@ public class MultiSourceFilter implements Filter, ReusableSink {
                        while (true) {
                                /* wait for source to be set. */
                                OutputStream outputStream;
+                               Source source;
                                logger.finest("Entering synchronized block...");
                                synchronized (syncObject) {
                                        logger.finest("Entered synchronized block.");
+                                       source = this.source;
                                        while (source == null) {
                                                try {
                                                        logger.finest("Waiting for source to connect...");
@@ -145,6 +147,7 @@ public class MultiSourceFilter implements Filter, ReusableSink {
                                                } catch (InterruptedException ie1) {
                                                        /* ignore, keep waiting. */
                                                }
+                                               source = this.source;
                                        }
                                        outputStream = pipedOutputStream;
                                }