Github user twalthr commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3127#discussion_r97354898
  
    --- Diff: 
flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java 
---
    @@ -1916,6 +1918,50 @@ else if (value instanceof Row) {
                }
        }
     
    +   public static <X> TypeInformation<X> getForCollection(Iterable<X> 
value) {
    +           return new TypeExtractor().privateGetForIterable(value);
    +   }
    +
    +   public static <X> TypeInformation<X> getForCollection(X[] value) {
    +           return new 
TypeExtractor().privateGetForIterable(Arrays.asList(value));
    +   }
    +
    +   @SuppressWarnings({ "unchecked", "rawtypes" })
    +   private <X> TypeInformation<X> privateGetForIterable(Iterable<X> value) 
{
    +           checkNotNull(value);
    +
    +           Iterator<X> it = value.iterator();
    +           X v = checkNotNull(it.next());
    --- End diff --
    
    Calling `next` without checking can result in `NoSuchElementException`. We 
should check that first and throw a helpful exception.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to