Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConfigMapping does not handle java.nio.file.Path by default #19613

Closed
vladykin opened this issue Aug 24, 2021 · 2 comments · Fixed by #20168
Closed

ConfigMapping does not handle java.nio.file.Path by default #19613

vladykin opened this issue Aug 24, 2021 · 2 comments · Fixed by #20168
Assignees
Labels
area/config kind/bug Something isn't working
Milestone

Comments

@vladykin
Copy link

vladykin commented Aug 24, 2021

Describe the bug

When I have a property with type java.nio.file.Path in ConfigMapping like this

@ConfigMapping(prefix = "myconfig")
public interface MyConfig {

  Path workdir();
}

I get build error

2021-08-24 15:05:14,301 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.arc.deployment.ConfigBuildStep#generateConfigClasses threw an exception: java.lang.IllegalArgumentException: Configuration methods cannot accept parameters
	at io.smallrye.config.ConfigMappingInterface.getProperties(ConfigMappingInterface.java:597)
	at io.smallrye.config.ConfigMappingInterface.createConfigurationInterface(ConfigMappingInterface.java:559)
	at io.smallrye.config.ConfigMappingInterface.access$000(ConfigMappingInterface.java:27)
	at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:32)
	at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:30)
	at java.base/java.lang.ClassValue.getFromHashMap(ClassValue.java:228)
	at java.base/java.lang.ClassValue.getFromBackup(ClassValue.java:210)
	at java.base/java.lang.ClassValue.get(ClassValue.java:116)
	at io.smallrye.config.ConfigMappingInterface.getConfigurationInterface(ConfigMappingInterface.java:61)
	at io.smallrye.config.ConfigMappingInterface.getSuperTypes(ConfigMappingInterface.java:573)
	at io.smallrye.config.ConfigMappingInterface.getSuperTypes(ConfigMappingInterface.java:579)
	at io.smallrye.config.ConfigMappingInterface.getSuperTypes(ConfigMappingInterface.java:579)
	at io.smallrye.config.ConfigMappingInterface.createConfigurationInterface(ConfigMappingInterface.java:557)
	at io.smallrye.config.ConfigMappingInterface.access$000(ConfigMappingInterface.java:27)
	at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:32)
	at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:30)
	at java.base/java.lang.ClassValue.getFromHashMap(ClassValue.java:228)
	at java.base/java.lang.ClassValue.getFromBackup(ClassValue.java:210)
	at java.base/java.lang.ClassValue.get(ClassValue.java:116)
	at io.smallrye.config.ConfigMappingInterface.getConfigurationInterface(ConfigMappingInterface.java:61)
	at io.smallrye.config.ConfigMappingInterface.getPropertyDef(ConfigMappingInterface.java:652)
	at io.smallrye.config.ConfigMappingInterface.getProperties(ConfigMappingInterface.java:602)
	at io.smallrye.config.ConfigMappingInterface.createConfigurationInterface(ConfigMappingInterface.java:559)
	at io.smallrye.config.ConfigMappingInterface.access$000(ConfigMappingInterface.java:27)
	at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:32)
	at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:30)
	at java.base/java.lang.ClassValue.getFromHashMap(ClassValue.java:228)
	at java.base/java.lang.ClassValue.getFromBackup(ClassValue.java:210)
	at java.base/java.lang.ClassValue.get(ClassValue.java:116)
	at io.smallrye.config.ConfigMappingInterface.getConfigurationInterface(ConfigMappingInterface.java:61)
	at io.smallrye.config.ConfigMappingLoader.getConfigMappingsMetadata(ConfigMappingLoader.java:26)
	at io.quarkus.arc.deployment.ConfigBuildStep.generateConfigClasses(ConfigBuildStep.java:289)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at java.base/java.lang.Thread.run(Thread.java:831)
	at org.jboss.threads.JBossThread.run(JBossThread.java:501)

	at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:415)
	at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:275)
	at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:66)
	at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:91)
	at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:424)
	at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:64)
	at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:136)
	at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:93)
	at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:145)
	at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:63)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.arc.deployment.ConfigBuildStep#generateConfigClasses threw an exception: java.lang.IllegalArgumentException: Configuration methods cannot accept parameters
	at io.smallrye.config.ConfigMappingInterface.getProperties(ConfigMappingInterface.java:597)
	at io.smallrye.config.ConfigMappingInterface.createConfigurationInterface(ConfigMappingInterface.java:559)
	at io.smallrye.config.ConfigMappingInterface.access$000(ConfigMappingInterface.java:27)
	at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:32)
	at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:30)
	at java.base/java.lang.ClassValue.getFromHashMap(ClassValue.java:228)
	at java.base/java.lang.ClassValue.getFromBackup(ClassValue.java:210)
	at java.base/java.lang.ClassValue.get(ClassValue.java:116)
	at io.smallrye.config.ConfigMappingInterface.getConfigurationInterface(ConfigMappingInterface.java:61)
	at io.smallrye.config.ConfigMappingInterface.getSuperTypes(ConfigMappingInterface.java:573)
	at io.smallrye.config.ConfigMappingInterface.getSuperTypes(ConfigMappingInterface.java:579)
	at io.smallrye.config.ConfigMappingInterface.getSuperTypes(ConfigMappingInterface.java:579)
	at io.smallrye.config.ConfigMappingInterface.createConfigurationInterface(ConfigMappingInterface.java:557)
	at io.smallrye.config.ConfigMappingInterface.access$000(ConfigMappingInterface.java:27)
	at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:32)
	at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:30)
	at java.base/java.lang.ClassValue.getFromHashMap(ClassValue.java:228)
	at java.base/java.lang.ClassValue.getFromBackup(ClassValue.java:210)
	at java.base/java.lang.ClassValue.get(ClassValue.java:116)
	at io.smallrye.config.ConfigMappingInterface.getConfigurationInterface(ConfigMappingInterface.java:61)
	at io.smallrye.config.ConfigMappingInterface.getPropertyDef(ConfigMappingInterface.java:652)
	at io.smallrye.config.ConfigMappingInterface.getProperties(ConfigMappingInterface.java:602)
	at io.smallrye.config.ConfigMappingInterface.createConfigurationInterface(ConfigMappingInterface.java:559)
	at io.smallrye.config.ConfigMappingInterface.access$000(ConfigMappingInterface.java:27)
	at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:32)
	at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:30)
	at java.base/java.lang.ClassValue.getFromHashMap(ClassValue.java:228)
	at java.base/java.lang.ClassValue.getFromBackup(ClassValue.java:210)
	at java.base/java.lang.ClassValue.get(ClassValue.java:116)
	at io.smallrye.config.ConfigMappingInterface.getConfigurationInterface(ConfigMappingInterface.java:61)
	at io.smallrye.config.ConfigMappingLoader.getConfigMappingsMetadata(ConfigMappingLoader.java:26)
	at io.quarkus.arc.deployment.ConfigBuildStep.generateConfigClasses(ConfigBuildStep.java:289)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at java.base/java.lang.Thread.run(Thread.java:831)
	at org.jboss.threads.JBossThread.run(JBossThread.java:501)

	at io.quarkus.builder.Execution.run(Execution.java:116)
	at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
	at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:151)
	at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:413)
	... 9 more
Caused by: java.lang.IllegalArgumentException: Configuration methods cannot accept parameters
	at io.smallrye.config.ConfigMappingInterface.getProperties(ConfigMappingInterface.java:597)
	at io.smallrye.config.ConfigMappingInterface.createConfigurationInterface(ConfigMappingInterface.java:559)
	at io.smallrye.config.ConfigMappingInterface.access$000(ConfigMappingInterface.java:27)
	at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:32)
	at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:30)
	at java.base/java.lang.ClassValue.getFromHashMap(ClassValue.java:228)
	at java.base/java.lang.ClassValue.getFromBackup(ClassValue.java:210)
	at java.base/java.lang.ClassValue.get(ClassValue.java:116)
	at io.smallrye.config.ConfigMappingInterface.getConfigurationInterface(ConfigMappingInterface.java:61)
	at io.smallrye.config.ConfigMappingInterface.getSuperTypes(ConfigMappingInterface.java:573)
	at io.smallrye.config.ConfigMappingInterface.getSuperTypes(ConfigMappingInterface.java:579)
	at io.smallrye.config.ConfigMappingInterface.getSuperTypes(ConfigMappingInterface.java:579)
	at io.smallrye.config.ConfigMappingInterface.createConfigurationInterface(ConfigMappingInterface.java:557)
	at io.smallrye.config.ConfigMappingInterface.access$000(ConfigMappingInterface.java:27)
	at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:32)
	at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:30)
	at java.base/java.lang.ClassValue.getFromHashMap(ClassValue.java:228)
	at java.base/java.lang.ClassValue.getFromBackup(ClassValue.java:210)
	at java.base/java.lang.ClassValue.get(ClassValue.java:116)
	at io.smallrye.config.ConfigMappingInterface.getConfigurationInterface(ConfigMappingInterface.java:61)
	at io.smallrye.config.ConfigMappingInterface.getPropertyDef(ConfigMappingInterface.java:652)
	at io.smallrye.config.ConfigMappingInterface.getProperties(ConfigMappingInterface.java:602)
	at io.smallrye.config.ConfigMappingInterface.createConfigurationInterface(ConfigMappingInterface.java:559)
	at io.smallrye.config.ConfigMappingInterface.access$000(ConfigMappingInterface.java:27)
	at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:32)
	at io.smallrye.config.ConfigMappingInterface$1.computeValue(ConfigMappingInterface.java:30)
	at java.base/java.lang.ClassValue.getFromHashMap(ClassValue.java:228)
	at java.base/java.lang.ClassValue.getFromBackup(ClassValue.java:210)
	at java.base/java.lang.ClassValue.get(ClassValue.java:116)
	at io.smallrye.config.ConfigMappingInterface.getConfigurationInterface(ConfigMappingInterface.java:61)
	at io.smallrye.config.ConfigMappingLoader.getConfigMappingsMetadata(ConfigMappingLoader.java:26)
	at io.quarkus.arc.deployment.ConfigBuildStep.generateConfigClasses(ConfigBuildStep.java:289)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at java.base/java.lang.Thread.run(Thread.java:831)
	at org.jboss.threads.JBossThread.run(JBossThread.java:501)

Looks like Quarkus is scanning java.nio.file.Path interface and trying to create a synthetic class implementing this interface.

This does not happen when I explicitly specify Converter:

@ConfigMapping(prefix = "myconfig")
public interface MyConfig {

  @WithConverter(PathConverter.class)
  Path workdir();
}

Expected behavior

I'd love Quarkus to support java.nio.file.Path out-of-the-box without extra annotations, like it's supported for @ConfigProperty.

Output of uname -a or ver

Linux 5.10.52-gentoo #1 SMP Thu Jul 29 22:16:28 MSK 2021 x86_64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz GenuineIntel GNU/Linux

Output of java -version

openjdk version "11.0.12" 2021-07-20 LTS
OpenJDK Runtime Environment Zulu11.50+19-CA (build 11.0.12+7-LTS)
OpenJDK 64-Bit Server VM Zulu11.50+19-CA (build 11.0.12+7-LTS, mixed mode)

Quarkus version or git rev

2.1.3.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.6.3

@vladykin vladykin added the kind/bug Something isn't working label Aug 24, 2021
@famod
Copy link
Member

famod commented Aug 24, 2021

/cc @radcortez

@radcortez
Copy link
Member

This will be fixed in the next SR Config version.

@radcortez radcortez self-assigned this Sep 7, 2021
@quarkus-bot quarkus-bot bot added this to the 2.3 - main milestone Sep 15, 2021
@gsmet gsmet modified the milestones: 2.3.0.CR1, 2.2.4.Final Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants