Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions java/src/com/facebook/watchman/WatchmanClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;

import static com.google.common.base.Preconditions.checkNotNull;

Expand Down Expand Up @@ -149,7 +150,7 @@ public Boolean apply(@Nullable Map<String, Object> input) {
}
return wasDeleted;
}
});
}, MoreExecutors.directExecutor());
}

@Override
Expand Down Expand Up @@ -181,7 +182,8 @@ public SubscriptionDescriptor apply(@Nullable Map<String, Object> input) {
// TODO remove subscription descriptor from `subscriptions` if we got an error from wman
return result;
}
});
},
MoreExecutors.directExecutor());
}

@Override
Expand Down Expand Up @@ -228,7 +230,8 @@ public ListenableFuture<Boolean> apply(@Nullable SubscriptionDescriptor input) {
public Boolean apply(@Nullable List<Boolean> input) {
return !Collections2.filter(input, Predicates.equalTo(false)).isEmpty();
}
});
},
MoreExecutors.directExecutor());
}

/**
Expand Down
11 changes: 9 additions & 2 deletions java/src/com/facebook/watchman/bser/BserDeserializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.nio.ByteOrder;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.MalformedInputException;
import java.nio.charset.StandardCharsets;

import java.util.ArrayList;
Expand Down Expand Up @@ -219,9 +220,10 @@ private Number deserializeNumber(ByteBuffer buffer, byte type) throws IOExceptio
}
}

private String deserializeString(ByteBuffer buffer) throws IOException {
private Object deserializeString(ByteBuffer buffer) throws IOException {
byte intType = buffer.get();
int len = deserializeIntLen(buffer, intType);
int pos = buffer.position();

// We use a CharsetDecoder here instead of String(byte[], Charset)
// because we want it to throw an exception for any non-UTF-8 input.
Expand All @@ -234,6 +236,11 @@ private String deserializeString(ByteBuffer buffer) throws IOException {
//
// See: http://java-performance.info/string-intern-in-java-6-7-8/
return utf8Decoder.decode(buffer).toString().intern();
} catch (MalformedInputException notUtf8) {
buffer.position(pos);
byte[] b = new byte[buffer.remaining()];
buffer.get(b);
return b;
} finally {
buffer.limit(buffer.capacity());
}
Expand Down Expand Up @@ -272,7 +279,7 @@ private Map<String, Object> deserializeObject(ByteBuffer buffer) throws IOExcept
"Unrecognized BSER object key type %d, expected string",
stringType));
}
String key = deserializeString(buffer);
String key = (String) deserializeString(buffer);
Object value = deserializeRecursive(buffer);
map.put(key, value);
}
Expand Down
3 changes: 3 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
install:
- cd java
- mvn install -DskipTests