diff options
Diffstat (limited to 'java/src/main/java/com/google/protobuf/AbstractMessageLite.java')
-rw-r--r-- | java/src/main/java/com/google/protobuf/AbstractMessageLite.java | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/java/src/main/java/com/google/protobuf/AbstractMessageLite.java b/java/src/main/java/com/google/protobuf/AbstractMessageLite.java index 77b27370..9926f3db 100644 --- a/java/src/main/java/com/google/protobuf/AbstractMessageLite.java +++ b/java/src/main/java/com/google/protobuf/AbstractMessageLite.java @@ -92,6 +92,14 @@ public abstract class AbstractMessageLite implements MessageLite { } /** + * Package private helper method for AbstractParser to create + * UninitializedMessageException. + */ + UninitializedMessageException newUninitializedMessageException() { + return new UninitializedMessageException(this); + } + + /** * A partial implementation of the {@link Message.Builder} interface which * implements as many methods of that interface as possible in terms of * other methods. @@ -307,10 +315,12 @@ public abstract class AbstractMessageLite implements MessageLite { */ protected static <T> void addAll(final Iterable<T> values, final Collection<? super T> list) { - for (final T value : values) { - if (value == null) { - throw new NullPointerException(); - } + if (values instanceof LazyStringList) { + // For StringOrByteStringLists, check the underlying elements to avoid + // forcing conversions of ByteStrings to Strings. + checkForNullValues(((LazyStringList) values).getUnderlyingElements()); + } else { + checkForNullValues(values); } if (values instanceof Collection) { final Collection<T> collection = (Collection<T>) values; @@ -321,5 +331,13 @@ public abstract class AbstractMessageLite implements MessageLite { } } } + + private static void checkForNullValues(final Iterable<?> values) { + for (final Object value : values) { + if (value == null) { + throw new NullPointerException(); + } + } + } } } |