Error in filtered push replication

I need to filter out some documents from being pushed to the sync gateway from the client. To that I’ve created a filter function as follows and assign it to my push replication,

I do not want to replicate documents with “type” attribute equal to “Section”

My filter function is…

database.setFilter(“myFilter”,new ReplicationFilter() {
public boolean filter(SavedRevision revision, Map<String, Object> params) {
return false;
return true;

    Replication pushReplication = database.createPushReplication(syncUrl);

But my problem is, other documents also (type attribute is not equal to “Section”) do not replicate to the sync gateway. In fact I cannot see any other doc is being replicated to the server. What I’m doing wrong here?

I get this exception in the following line…

…" if(revision.getProperty(“type”).equals(“Section”)){"…

08-11 20:22:40.692 12220-12390/ E/Sync﹕ PullerInternal finished
08-11 20:22:40.692 12220-12381/ E/RemoteRequest﹕ RemoteRequestCompletionBlock throw Exception
java.lang.NullPointerException: Attempt to invoke virtual method ‘boolean java.lang.Object.equals(java.lang.Object)’ on a null object reference
at com.couchbase.lite.Database.runFilter(
at com.couchbase.lite.Database.changesSince(
at com.couchbase.lite.replicator.PusherInternal.beginReplicating(
at com.couchbase.lite.replicator.ReplicationInternal$9.onCompletion(
at java.util.concurrent.Executors$
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(
at java.util.concurrent.ScheduledThreadPoolExecutor$
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$

Hi @cyclops15,

It looks like some documents may not have a type property and it’s causing the null pointer exception.

Does it work if you check for the existence of the type property?

if (revision.getProperty("type") != null && revision.getProperty("type").equals("Section")) {


Thank you James for pointing that out, it is working fine after checking for existence. However I’m absolutely sure that every document has a “type” property. Not sure why it has to check for existence. Anyway, problem solved. Thank you very much. :wink:

Deleted revisions (“tombstones”) won’t have a type property, or any other properties besides _deleted.