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
Original file line number Diff line number Diff line change
Expand Up @@ -248,62 +248,6 @@ public BuilderType mergeFrom(
return (BuilderType) this;
}

/**
* An InputStream implementations which reads from some other InputStream but is limited to a
* particular number of bytes. Used by mergeDelimitedFrom(). This is intentionally
* package-private so that UnknownFieldSet can share it.
*/
static final class LimitedInputStream extends FilterInputStream {
private int limit;

LimitedInputStream(InputStream in, int limit) {
super(in);
this.limit = limit;
}

@Override
public int available() throws IOException {
return Math.min(super.available(), limit);
}

@Override
public int read() throws IOException {
if (limit <= 0) {
return -1;
}
final int result = super.read();
if (result >= 0) {
--limit;
}
return result;
}

@Override
public int read(final byte[] b, final int off, int len) throws IOException {
if (limit <= 0) {
return -1;
}
len = Math.min(len, limit);
final int result = super.read(b, off, len);
if (result >= 0) {
limit -= result;
}
return result;
}

@Override
public long skip(final long n) throws IOException {
// because we take the minimum of an int and a long, result is guaranteed to be
// less than or equal to Integer.MAX_INT so this cast is safe
int result = (int) super.skip(Math.min(n, limit));
if (result >= 0) {
// if the superclass adheres to the contract for skip, this condition is always true
limit -= result;
}
return result;
}
}

@Override
public boolean mergeDelimitedFrom(
final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

package com.google.protobuf;

import com.google.protobuf.AbstractMessageLite.Builder.LimitedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
Expand Down
2,014 changes: 1,007 additions & 1,007 deletions protobuf-api/src/main/java/com/google/protobuf/DescriptorProtos.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*
* @author [email protected] Kenton Varda
*/
public final class DynamicMessage extends AbstractMessage {
public final class DynamicMessage extends FlattenedAbstractMessage {
private final Descriptor type;
private final FieldSet<FieldDescriptor> fields;
private final FieldDescriptor[] oneofCases;
Expand Down Expand Up @@ -293,7 +293,7 @@ private void verifyOneofContainingType(OneofDescriptor oneof) {
// =================================================================

/** Builder for {@link DynamicMessage}s. */
public static final class Builder extends AbstractMessage.Builder<Builder> {
public static final class Builder extends FlattenedAbstractMessage.Builder<Builder> {
private final Descriptor type;
private FieldSet.Builder<FieldDescriptor> fields;
private final FieldDescriptor[] oneofCases;
Expand Down
Loading