You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "Yura Atamanchuk (Jira)" <ji...@apache.org> on 2019/11/20 10:56:00 UTC
[jira] [Created] (BEAM-8785) Default value for enum runtime option
doesn't work
Yura Atamanchuk created BEAM-8785:
-------------------------------------
Summary: Default value for enum runtime option doesn't work
Key: BEAM-8785
URL: https://issues.apache.org/jira/browse/BEAM-8785
Project: Beam
Issue Type: Bug
Components: sdk-java-core
Affects Versions: 2.15.0
Reporter: Yura Atamanchuk
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
--
This message was sent by Atlassian Jira
(v8.3.4#803005)