Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion api/src/main/java/io/grpc/InternalMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static <T> Object parsedValue(Key<T> key, T value) {
* with some values pre-parsed. Metadata will mutate the passed in array.
*
* @param usedNames The number of names used.
* @param namesAndValues An array of iterleaved names and values,
* @param namesAndValues An array of interleaved names and values,
* with each name (at even indices) represented as a byte array,
* and each value (at odd indices) represented as either a byte
* array or an object returned by the {@link #parsedValue}
Expand Down
14 changes: 8 additions & 6 deletions api/src/main/java/io/grpc/Metadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ public String parseAsciiString(String serialized) {
/**
* Constructor called by the transport layer when it receives partially-parsed metadata.
* Metadata will mutate the passed in array.
*
* @param usedNames the number of names
* @param namesAndValues an array of interleaved names and values, with each name
* (at even indices) represented by a byte array, and values (at odd indices) as
* described by {@link InternalMetadata#newMetadataWithParsedValues}.
*/
Metadata(int usedNames, Object[] namesAndValues) {
assert (namesAndValues.length & 1) == 0
Expand Down Expand Up @@ -188,9 +193,9 @@ private Object valueAsBytesOrStream(int i) {
private <T> T valueAsT(int i, Key<T> key) {
Object value = value(i);
if (value instanceof byte[]) {
return key.parseBytes((byte[]) value(i));
return key.parseBytes((byte[]) value);
} else {
return ((LazyValue<?>) value(i)).toObject(key);
return ((LazyValue<?>) value).toObject(key);
}
}

Expand Down Expand Up @@ -931,10 +936,7 @@ byte[] toBytes() {
<T2> T2 toObject(Key<T2> key) {
if (key.serializesToStreams()) {
BinaryStreamMarshaller<T2> marshaller = getBinaryStreamMarshaller(key);
if (marshaller == this.marshaller) {
// The marshallers match so T2 == T.
return (T2) value;
} else if (marshaller != null) {
if (marshaller != null) {
return marshaller.parseStream(toStream());
}
}
Expand Down
2 changes: 1 addition & 1 deletion api/src/test/java/io/grpc/MetadataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ public void createFromPartial() {

Metadata h2 = new Metadata(3, partial);
assertEquals(new Fish(LANCE), h2.get(KEY));
assertSame(anotherSalmon, h2.get(KEY_STREAMED));
assertEquals(anotherSalmon, h2.get(KEY_STREAMED));
assertSame(anotherSalmon, h2.get(KEY_IMMUTABLE));
}

Expand Down