[ 
https://issues.apache.org/jira/browse/DELTASPIKE-1333?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Thomas Andraschko reassigned DELTASPIKE-1333:
---------------------------------------------

    Assignee: Mark Struberg

> Support default methods in interface based configuration
> --------------------------------------------------------
>
>                 Key: DELTASPIKE-1333
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-1333
>             Project: DeltaSpike
>          Issue Type: Improvement
>          Components: Configuration
>    Affects Versions: 1.8.1
>         Environment: Java 8, DeltaSpike 1.8.1
>            Reporter: Niels Ull Harremoes
>            Assignee: Mark Struberg
>            Priority: Minor
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> I wanted to implement a default method in one of my configuration methods as 
> a simple way to configure a Duration:
> {code:java}
> @Configuration
> interface CacheConfig {
>   @ConfigProperty(name = "cache.lifetime", defaultValue = "P1D")
>   String cacheLifetime();
>   default Duration getCacheLifetimeDuration() {
>     try {
>        return Duration.parse(cacheLifetime());
>     } catch (DateTimeParseException e) {
>         ...
>   }
> }
> {code}
> However, a runtime I get the error
> {quote}java.lang.UnsupportedOperationException: public default 
> java.time.Duration com.example.CacheConfig.getLifetimeDuration() doesn't have 
> @ConfigProperty and therefore is illegal
> {quote}
> It would be nice if default methods were not processed.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to