Skip to content

Commit

Permalink
Merge tag 'refs/tags/sync-piper' into sync-stage
Browse files Browse the repository at this point in the history
  • Loading branch information
acozzette committed Aug 25, 2021
2 parents 38f6e15 + f78fefc commit 50ea0dc
Show file tree
Hide file tree
Showing 138 changed files with 2,128 additions and 1,390 deletions.
57 changes: 36 additions & 21 deletions benchmarks/util/result_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,29 +300,44 @@ def get_result_from_file(cpp_file="",

return __results


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-cpp", "--cpp_input_file",
help="The CPP benchmark result file's name",
default="")
parser.add_argument("-java", "--java_input_file",
help="The Java benchmark result file's name",
default="")
parser.add_argument("-python", "--python_input_file",
help="The Python benchmark result file's name",
default="")
parser.add_argument("-go", "--go_input_file",
help="The golang benchmark result file's name",
default="")
parser.add_argument("-node", "--node_input_file",
help="The node.js benchmark result file's name",
default="")
parser.add_argument("-php", "--php_input_file",
help="The pure php benchmark result file's name",
default="")
parser.add_argument("-php_c", "--php_c_input_file",
help="The php with c ext benchmark result file's name",
default="")
parser.add_argument(
"-cpp",
"--cpp_input_file",
help="The CPP benchmark result file's name",
default="")
parser.add_argument(
"-java",
"--java_input_file",
help="The Java benchmark result file's name",
default="")
parser.add_argument(
"-python",
"--python_input_file",
help="The Python benchmark result file's name",
default="")
parser.add_argument(
"-go",
"--go_input_file",
help="The golang benchmark result file's name",
default="")
parser.add_argument(
"-node",
"--node_input_file",
help="The node.js benchmark result file's name",
default="")
parser.add_argument(
"-php",
"--php_input_file",
help="The pure php benchmark result file's name",
default="")
parser.add_argument(
"-php_c",
"--php_c_input_file",
help="The php with c ext benchmark result file's name",
default="")
args = parser.parse_args()

results = get_result_from_file(
Expand Down
44 changes: 23 additions & 21 deletions java/core/src/main/java/com/google/protobuf/CodedInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static CodedInputStream newInstance(final InputStream input, int bufferSi
throw new IllegalArgumentException("bufferSize must be > 0");
}
if (input == null) {
// TODO(nathanmittler): Ideally we should throw here. This is done for backward compatibility.
// Ideally we would throw here. This is done for backward compatibility.
return newInstance(EMPTY_BYTE_ARRAY);
}
return new StreamDecoder(input, bufferSize);
Expand Down Expand Up @@ -1146,7 +1146,7 @@ public int readRawLittleEndian32() throws IOException {

final byte[] buffer = this.buffer;
pos = tempPos + FIXED32_SIZE;
return (((buffer[tempPos] & 0xff))
return ((buffer[tempPos] & 0xff)
| ((buffer[tempPos + 1] & 0xff) << 8)
| ((buffer[tempPos + 2] & 0xff) << 16)
| ((buffer[tempPos + 3] & 0xff) << 24));
Expand All @@ -1162,7 +1162,7 @@ public long readRawLittleEndian64() throws IOException {

final byte[] buffer = this.buffer;
pos = tempPos + FIXED64_SIZE;
return (((buffer[tempPos] & 0xffL))
return ((buffer[tempPos] & 0xffL)
| ((buffer[tempPos + 1] & 0xffL) << 8)
| ((buffer[tempPos + 2] & 0xffL) << 16)
| ((buffer[tempPos + 3] & 0xffL) << 24)
Expand Down Expand Up @@ -1871,7 +1871,7 @@ public int readRawLittleEndian32() throws IOException {
}

pos = tempPos + FIXED32_SIZE;
return (((UnsafeUtil.getByte(tempPos) & 0xff))
return ((UnsafeUtil.getByte(tempPos) & 0xff)
| ((UnsafeUtil.getByte(tempPos + 1) & 0xff) << 8)
| ((UnsafeUtil.getByte(tempPos + 2) & 0xff) << 16)
| ((UnsafeUtil.getByte(tempPos + 3) & 0xff) << 24));
Expand All @@ -1886,7 +1886,7 @@ public long readRawLittleEndian64() throws IOException {
}

pos = tempPos + FIXED64_SIZE;
return (((UnsafeUtil.getByte(tempPos) & 0xffL))
return ((UnsafeUtil.getByte(tempPos) & 0xffL)
| ((UnsafeUtil.getByte(tempPos + 1) & 0xffL) << 8)
| ((UnsafeUtil.getByte(tempPos + 2) & 0xffL) << 16)
| ((UnsafeUtil.getByte(tempPos + 3) & 0xffL) << 24)
Expand Down Expand Up @@ -2014,11 +2014,16 @@ private ByteBuffer slice(long begin, long end) throws IOException {
int prevPos = buffer.position();
int prevLimit = buffer.limit();
try {
// Casts to Buffer here are required for Java 8 compatibility
// no matter what tricorder tells you. see
// https://issues.apache.org/jira/browse/MRESOLVER-85
((Buffer) buffer).position(bufferPos(begin));
((Buffer) buffer).limit(bufferPos(end));
return buffer.slice();
} catch (IllegalArgumentException e) {
throw InvalidProtocolBufferException.truncatedMessage();
InvalidProtocolBufferException ex = InvalidProtocolBufferException.truncatedMessage();
ex.initCause(e);
throw ex;
} finally {
((Buffer) buffer).position(prevPos);
((Buffer) buffer).limit(prevLimit);
Expand Down Expand Up @@ -2660,7 +2665,7 @@ public int readRawLittleEndian32() throws IOException {

final byte[] buffer = this.buffer;
pos = tempPos + FIXED32_SIZE;
return (((buffer[tempPos] & 0xff))
return ((buffer[tempPos] & 0xff)
| ((buffer[tempPos + 1] & 0xff) << 8)
| ((buffer[tempPos + 2] & 0xff) << 16)
| ((buffer[tempPos + 3] & 0xff) << 24));
Expand Down Expand Up @@ -2987,7 +2992,7 @@ private List<byte[]> readRawBytesSlowPathRemainingChunks(int sizeLeft) throws IO
// by allocating and reading only a small chunk at a time, so that the
// malicious message must actually *be* extremely large to cause
// problems. Meanwhile, we limit the allowed size of a message elsewhere.
final List<byte[]> chunks = new ArrayList<byte[]>();
final List<byte[]> chunks = new ArrayList<>();

while (sizeLeft > 0) {
// TODO(nathanmittler): Consider using a value larger than DEFAULT_BUFFER_SIZE.
Expand Down Expand Up @@ -3134,16 +3139,16 @@ private void skipRawBytesSlowPath(final int size) throws IOException {
*/
private static final class IterableDirectByteBufferDecoder extends CodedInputStream {
/** The object that need to decode. */
private Iterable<ByteBuffer> input;
private final Iterable<ByteBuffer> input;
/** The {@link Iterator} with type {@link ByteBuffer} of {@code input} */
private Iterator<ByteBuffer> iterator;
private final Iterator<ByteBuffer> iterator;
/** The current ByteBuffer; */
private ByteBuffer currentByteBuffer;
/**
* If {@code true}, indicates that all the buffer are backing a {@link ByteString} and are
* If {@code true}, indicates that all the buffers are backing a {@link ByteString} and are
* therefore considered to be an immutable input source.
*/
private boolean immutable;
private final boolean immutable;
/**
* If {@code true}, indicates that calls to read {@link ByteString} or {@code byte[]}
* <strong>may</strong> return slices of the underlying buffer, rather than copies.
Expand Down Expand Up @@ -3516,8 +3521,7 @@ public ByteString readBytes() throws IOException {
currentByteBufferPos += size;
return result;
} else {
byte[] bytes;
bytes = new byte[size];
byte[] bytes = new byte[size];
UnsafeUtil.copyMemory(currentByteBufferPos, bytes, 0, size);
currentByteBufferPos += size;
return ByteString.wrap(bytes);
Expand Down Expand Up @@ -3738,7 +3742,7 @@ public int readRawLittleEndian32() throws IOException {
if (currentRemaining() >= FIXED32_SIZE) {
long tempPos = currentByteBufferPos;
currentByteBufferPos += FIXED32_SIZE;
return (((UnsafeUtil.getByte(tempPos) & 0xff))
return ((UnsafeUtil.getByte(tempPos) & 0xff)
| ((UnsafeUtil.getByte(tempPos + 1) & 0xff) << 8)
| ((UnsafeUtil.getByte(tempPos + 2) & 0xff) << 16)
| ((UnsafeUtil.getByte(tempPos + 3) & 0xff) << 24));
Expand All @@ -3754,7 +3758,7 @@ public long readRawLittleEndian64() throws IOException {
if (currentRemaining() >= FIXED64_SIZE) {
long tempPos = currentByteBufferPos;
currentByteBufferPos += FIXED64_SIZE;
return (((UnsafeUtil.getByte(tempPos) & 0xffL))
return ((UnsafeUtil.getByte(tempPos) & 0xffL)
| ((UnsafeUtil.getByte(tempPos + 1) & 0xffL) << 8)
| ((UnsafeUtil.getByte(tempPos + 2) & 0xffL) << 16)
| ((UnsafeUtil.getByte(tempPos + 3) & 0xffL) << 24)
Expand Down Expand Up @@ -3875,11 +3879,6 @@ public byte[] readRawBytes(final int length) throws IOException {
* Try to get raw bytes from {@code input} with the size of {@code length} and copy to {@code
* bytes} array. If the size is bigger than the number of remaining bytes in the input, then
* throw {@code truncatedMessage} exception.
*
* @param bytes
* @param offset
* @param length
* @throws IOException
*/
private void readRawBytesTo(byte[] bytes, int offset, final int length) throws IOException {
if (length >= 0 && length <= remaining()) {
Expand Down Expand Up @@ -3966,6 +3965,9 @@ private ByteBuffer slice(int begin, int end) throws IOException {
int prevPos = currentByteBuffer.position();
int prevLimit = currentByteBuffer.limit();
try {
// casts to Buffer here are required for Java 8 compatibility
// no matter what tricorder tells you. see
// https://issues.apache.org/jira/browse/MRESOLVER-85
((Buffer) currentByteBuffer).position(begin);
((Buffer) currentByteBuffer).limit(end);
return currentByteBuffer.slice();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
* <p>The test mechanism employed here is based on the pattern in {@code
* com.google.common.util.concurrent.AbstractFutureFallbackAtomicHelperTest}
*
* <p> This test is temporarily disabled while we figure out how to fix the class loading used for
* <p>This test is temporarily disabled while we figure out how to fix the class loading used for
* testing lite functionality.
*/
@SuppressWarnings("JUnit4ClassUsedInJUnit3")
Expand Down
4 changes: 3 additions & 1 deletion java/core/src/test/java/com/google/protobuf/TestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -3758,7 +3758,9 @@ public void assertReflectionRepeatedSettersRejectNull(Message.Builder builder)

/** @param filePath The path relative to {@link #getTestDataDir}. */
public static String readTextFromFile(String filePath) {
return readBytesFromFile(filePath).toStringUtf8().replace(System.getProperty("line.separator"), "\n");
return readBytesFromFile(filePath)
.toStringUtf8()
.replace(System.getProperty("line.separator"), "\n");
}

private static File getTestDataDir() {
Expand Down
14 changes: 7 additions & 7 deletions java/kotlin/src/main/kotlin/com/google/protobuf/ExtensionList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ import com.google.protobuf.ExtensionLite
import com.google.protobuf.MessageLite

/**
* Implementation for ExtensionList and ExtensionListLite. Like [DslList], represents an
* unmodifiable view of a repeated proto field -- in this case, an extension field -- but
* supports querying the extension.
* Implementation for ExtensionList and ExtensionListLite. Like [DslList], represents an
* unmodifiable view of a repeated proto field -- in this case, an extension field -- but supports
* querying the extension.
*/
class ExtensionList<E, M : MessageLite> @OnlyForUseByGeneratedProtoCode constructor(
val extension: ExtensionLite<M, List<E>>,
private val delegate: List<E>
) : List<E> by delegate {
class ExtensionList<E, M : MessageLite>
@OnlyForUseByGeneratedProtoCode
constructor(val extension: ExtensionLite<M, List<E>>, private val delegate: List<E>) :
List<E> by delegate {
override fun iterator(): Iterator<E> = UnmodifiableIterator(delegate.iterator())

override fun listIterator(): ListIterator<E> = UnmodifiableListIterator(delegate.listIterator())
Expand Down
Loading

0 comments on commit 50ea0dc

Please sign in to comment.