Handle 0-length byte buffers in micro and nano protobufs

Change-Id: I845ee1ab1005d25c8d77a8c2ed801c0f7b7c847b
diff --git a/java/src/main/java/com/google/protobuf/micro/CodedInputStreamMicro.java b/java/src/main/java/com/google/protobuf/micro/CodedInputStreamMicro.java
index 3e3926c..cf1dc67 100644
--- a/java/src/main/java/com/google/protobuf/micro/CodedInputStreamMicro.java
+++ b/java/src/main/java/com/google/protobuf/micro/CodedInputStreamMicro.java
@@ -243,6 +243,8 @@
       final ByteStringMicro result = ByteStringMicro.copyFrom(buffer, bufferPos, size);
       bufferPos += size;
       return result;
+    } else if (size == 0) {
+      return ByteStringMicro.EMPTY;
     } else {
       // Slow path:  Build a byte array first then copy it.
       return ByteStringMicro.copyFrom(readRawBytes(size));
diff --git a/java/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java b/java/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java
index c5fea5a..df7fee0 100644
--- a/java/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java
+++ b/java/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java
@@ -236,6 +236,8 @@
       System.arraycopy(buffer, bufferPos, result, 0, size);
       bufferPos += size;
       return result;
+    } else if (size == 0) {
+      return WireFormatNano.EMPTY_BYTES;
     } else {
       // Slow path:  Build a byte array first then copy it.
       return readRawBytes(size);