From b4434f4312fbaf39869fd266c701dcfae0377095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lum=C3=ADr=20N=C3=A1vrat?= Date: Mon, 18 Sep 2023 12:28:37 +0200 Subject: [PATCH] #2102 PropertiesDefaultProvider at first try to load properties from classpath - check if commandSpec.userObject is null --- src/main/java/picocli/CommandLine.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/picocli/CommandLine.java b/src/main/java/picocli/CommandLine.java index d95fcb2d9..6a0f589ce 100644 --- a/src/main/java/picocli/CommandLine.java +++ b/src/main/java/picocli/CommandLine.java @@ -18979,7 +18979,11 @@ private static Properties loadProperties(CommandSpec commandSpec) { if (file.canRead()) { return createProperties(file, commandSpec); } else { - URL resource = commandSpec.userObject().getClass().getClassLoader().getResource(propertiesFileName); + Object userObject = commandSpec.userObject(); + if (userObject == null) { + userObject = commandSpec.commandLine; + } + URL resource = userObject.getClass().getClassLoader().getResource(propertiesFileName); Tracer tracer = CommandLine.tracer(); if (resource != null) { file = new File(resource.getFile());