You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by "Mark Struberg (Jira)" <ji...@apache.org> on 2022/04/08 07:46:00 UTC

[jira] [Closed] (DELTASPIKE-1333) Support default methods in interface based configuration

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

Mark Struberg closed DELTASPIKE-1333.
-------------------------------------
    Resolution: Won't Fix

sadly problematic as java proxies don't support this properly across different java versions.

> 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
(v8.20.1#820001)