Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/FilteringDispatcher.java
===================================================================
--- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/FilteringDispatcher.java	(revision 1771780)
+++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/FilteringDispatcher.java	(working copy)
@@ -21,7 +21,6 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 
 import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 
 import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
 import org.apache.jackrabbit.oak.spi.commit.Observer;
@@ -47,8 +46,10 @@
     @Override
     public void contentChanged(@Nonnull NodeState root,
                                @Nonnull CommitInfo info) {
-        if (info != FilteringObserver.NOOP_CHANGE) {
-            observer.contentChanged(before, root, info);
+        if (before != null) { // avoid null being passed as before to observer, only at startup
+            if (info != FilteringObserver.NOOP_CHANGE) {
+                observer.contentChanged(before, root, info);
+            }
         }
         before = root;
     }
Index: oak-core/src/test/java/org/apache/jackrabbit/oak/spi/commit/BackgroundObserverTest.java
===================================================================
--- oak-core/src/test/java/org/apache/jackrabbit/oak/spi/commit/BackgroundObserverTest.java	(revision 1771780)
+++ oak-core/src/test/java/org/apache/jackrabbit/oak/spi/commit/BackgroundObserverTest.java	(working copy)
@@ -206,7 +206,7 @@
             final long done = System.currentTimeMillis() + unit.toMillis(timeout);
             synchronized (this) {
                 while (!pausing && done > System.currentTimeMillis()) {
-                    this.wait();
+                    this.wait(100);
                 }
                 return pausing;
             }
@@ -216,7 +216,7 @@
             final long done = System.currentTimeMillis() + unit.toMillis(timeout);
             synchronized (this) {
                 while (pausing && done > System.currentTimeMillis()) {
-                    this.wait();
+                    this.wait(100);
                 }
                 return !pausing;
             }
@@ -280,7 +280,7 @@
         List<Pair> expected = new LinkedList<Pair>();
         NodeStateGenerator generator = new NodeStateGenerator();
         NodeState first = generator.next();
-        expected.add(new Pair(null, first));
+//        expected.add(new Pair(null, first));
         fo.contentChanged(first, CommitInfo.EMPTY);
         for (int i = 0; i < 100000; i++) {
             filter.excludeNext(true);
@@ -300,7 +300,7 @@
         List<Pair> expected = new LinkedList<Pair>();
         NodeStateGenerator generator = new NodeStateGenerator();
         NodeState first = generator.next();
-        expected.add(new Pair(null, first));
+//        expected.add(new Pair(null, first));
         fo.contentChanged(first, CommitInfo.EMPTY);
         NodeState previous = first;
         for (int i = 0; i < 10000; i++) {
@@ -326,8 +326,10 @@
         recorder.pause();
 
         // the first one will directly go to the recorder
+        NodeState initialHeldBack = generator.next();
+        fo.contentChanged(initialHeldBack, CommitInfo.EMPTY);
         NodeState firstIncluded = generator.next();
-        expected.add(new Pair(null, firstIncluded));
+        expected.add(new Pair(initialHeldBack, firstIncluded));
         fo.contentChanged(firstIncluded, CommitInfo.EMPTY);
 
         assertTrue("observer did not get called (yet?)", recorder.waitForPausing(5, TimeUnit.SECONDS));
@@ -408,7 +410,7 @@
         Random r = new Random(2343242); // seed: repeatable tests
         NodeStateGenerator generator = new NodeStateGenerator();
         NodeState first = generator.next();
-        expected.add(new Pair(null, first));
+//        expected.add(new Pair(null, first));
         fo.contentChanged(first, CommitInfo.EMPTY);
         NodeState previous = first;
         for (int i = 0; i < cnt; i++) {
Index: oak-core/src/test/java/org/apache/jackrabbit/oak/spi/commit/PrefilteringBackgroundObserverTest.java
===================================================================
--- oak-core/src/test/java/org/apache/jackrabbit/oak/spi/commit/PrefilteringBackgroundObserverTest.java	(revision 1771780)
+++ oak-core/src/test/java/org/apache/jackrabbit/oak/spi/commit/PrefilteringBackgroundObserverTest.java	(working copy)
@@ -165,8 +165,8 @@
         }
         executeRunnables(runnableQ, 10);
         
-        assertEquals(501, received.size());
-        assertEquals(500, resetCallCnt);
+        assertEquals(500, received.size()); // changed from 501 with OAK-5121
+        assertEquals(499, resetCallCnt); // changed from 500 with OAK-5121
         
         // Part 2 : run with filtersEvaluatedMapWithNullObservers - empty or null shouldn't matter, it's excluded in both cases
         received.clear();
@@ -233,7 +233,7 @@
                 // still 5 in the queue
                 new TestPattern(INCLUDED, 5, false, 0, 0),
                 // now we added 2, queue still not full
-                new TestPattern(EXCLUDED, 0 /* only flush*/, true, 10, 2)
+                new TestPattern(EXCLUDED, 0 /* only flush*/, true, 10, 1)
                 );
     }
     
@@ -249,7 +249,7 @@
                 // still 6 in the queue, of 7
                 new TestPattern(INCLUDED, 5, false, 0, 0, 6, 7),
                 // now we added 2 (one NOOP and one of those 5), so the queue got full (==7)
-                new TestPattern(EXCLUDED, 0 /* only flush*/, true, 5, 1, 7, 0)
+                new TestPattern(EXCLUDED, 0 /* only flush*/, true, 5, 0, 7, 0)
                 );
     }
     
@@ -283,7 +283,7 @@
                 // still full but it's ignored, so doesn't have any queue length effect
                 new TestPattern(INCLUDED, 3, false, 0, 0, 4, 4),
                 // adding 3 will not work, it will result in an overflow entry
-                new TestPattern(EXCLUDED, 0 /* only flush*/, true, 3, 1, 4, 0),
+                new TestPattern(EXCLUDED, 0 /* only flush*/, true, 3, 0, 4, 0),
                 new TestPattern(INCLUDED, 1, false, 0, 0, 0, 1),
                 new TestPattern(EXCLUDED, 0 /* only flush*/, true, 1, 0, 1, 0)
                 );
