You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by "Niels Ull Harremoes (JIRA)" <ji...@apache.org> on 2018/03/27 07:04:00 UTC
[jira] [Created] (DELTASPIKE-1333) Support default methods in
interface based configuration
Niels Ull Harremoes created DELTASPIKE-1333:
-----------------------------------------------
Summary: 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
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)