diff --git a/java/src/com/facebook/watchman/WatchmanClientImpl.java b/java/src/com/facebook/watchman/WatchmanClientImpl.java index 8d2445499058..acc89ce52fa5 100644 --- a/java/src/com/facebook/watchman/WatchmanClientImpl.java +++ b/java/src/com/facebook/watchman/WatchmanClientImpl.java @@ -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; @@ -149,7 +150,7 @@ public Boolean apply(@Nullable Map input) { } return wasDeleted; } - }); + }, MoreExecutors.directExecutor()); } @Override @@ -181,7 +182,8 @@ public SubscriptionDescriptor apply(@Nullable Map input) { // TODO remove subscription descriptor from `subscriptions` if we got an error from wman return result; } - }); + }, + MoreExecutors.directExecutor()); } @Override @@ -228,7 +230,8 @@ public ListenableFuture apply(@Nullable SubscriptionDescriptor input) { public Boolean apply(@Nullable List input) { return !Collections2.filter(input, Predicates.equalTo(false)).isEmpty(); } - }); + }, + MoreExecutors.directExecutor()); } /** diff --git a/java/src/com/facebook/watchman/bser/BserDeserializer.java b/java/src/com/facebook/watchman/bser/BserDeserializer.java index dbe9fba87139..34f8035c5c54 100644 --- a/java/src/com/facebook/watchman/bser/BserDeserializer.java +++ b/java/src/com/facebook/watchman/bser/BserDeserializer.java @@ -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; @@ -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. @@ -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()); } @@ -272,7 +279,7 @@ private Map 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); } diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 000000000000..d56f2f39566f --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,3 @@ +install: + - cd java + - mvn install -DskipTests