Details
-
Bug
-
Status: Resolved
-
P3
-
Resolution: Won't Fix
-
None
Description
Combination of ValueProvider, enums, @Default and missing option throws exception.
It can be reproduced with:
```
public enum E { A }
public interface Options extends PipelineOptions
{ @Default.Enum("A") ValueProvider<E> getE(); void setE(ValueProvider<E> e); }public static void main(String[] args)
{ Options options = PipelineOptionsFactory.fromArgs("").withValidation().as(Options.class); options.getE().get(); }```
Which fails with exception:
```
Exception in thread "main" java.lang.IllegalArgumentException: org.apache.beam.sdk.options.ValueProvider is not an enum typeException in thread "main" java.lang.IllegalArgumentException: org.apache.beam.sdk.options.ValueProvider is not an enum type at java.lang.Class.enumConstantDirectory(Class.java:3344) at java.lang.Enum.valueOf(Enum.java:232) at org.apache.beam.sdk.options.ProxyInvocationHandler.returnDefaultHelper(ProxyInvocationHandler.java:587) at org.apache.beam.sdk.options.ProxyInvocationHandler.getDefault(ProxyInvocationHandler.java:533) at org.apache.beam.sdk.options.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:158)
```
It seems like to get enum class of a value getter return type is directly casted into Class<Enum>, though in this case it is Class<ValueProvider<Enum>>. Probably it can be fixed - method return generic type is accessible via reflection