I am facing a situation where a previously working config load stopped working after the Lombok builder annotation was added to a Config class.
What's more perplexing is that Spring doesn't even fail startup or even warn in logs about this.
Here is an example:
@Configuration
@Data
@ConfigurationProperties(prefix = "app.export")
public class ExportConfig {
private String folderPath;
private Integer capacity;
private String filename;
private Map<String, ExportClientConfig> clientConfigurations;
public ExportClientConfig getClientConfiguration(String account){
return clientConfigurations.get(account);
}
}
Here, the Map<String, ExportClientConfig>
usually gets loaded with all values from the application.yaml
However, once @Builder is enabled on the ExportClientConfig
class, Spring quietly ignores the fact that its not able to construct ExportClientConfig during startup.
Relevant section of the application.yml
:
app:
export:
folderPath: /data/app/export
capacity: 50
filename: data.txt
clientConfigurations:
ACC1:
code: ACC1-ABC
center: 1001
payCode: SDLKFJS
ACC2:
code: ACC2-XYZ
center: 2001
payCode: DSFKHKSDJF
If the @Builder alone is reverted, everything works fine. Otherwise, the clientConfigurations
map is empty.
Is this behaviour documented anywhere? Is this expeted in Spring or, is it a bug?