11/* 
2-  * Copyright 2012-2024  the original author or authors. 
2+  * Copyright 2012-2025  the original author or authors. 
33 * 
44 * Licensed under the Apache License, Version 2.0 (the "License"); 
55 * you may not use this file except in compliance with the License. 
@@ -85,22 +85,34 @@ public void printBanner(Environment environment, Class<?> sourceClass, PrintStre
8585	 * @return a mutable list of property resolvers 
8686	 */ 
8787	protected  List <PropertyResolver > getPropertyResolvers (Environment  environment , Class <?> sourceClass ) {
88- 		MutablePropertySources  sources  = new  MutablePropertySources ();
89- 		if  (environment  instanceof  ConfigurableEnvironment  configurableEnvironment ) {
90- 			configurableEnvironment .getPropertySources ().forEach (sources ::addLast );
91- 		}
92- 		sources .addLast (getTitleSource (sourceClass ));
93- 		sources .addLast (getAnsiSource ());
94- 		sources .addLast (getVersionSource (sourceClass ));
9588		List <PropertyResolver > resolvers  = new  ArrayList <>();
96- 		resolvers .add (new  PropertySourcesPropertyResolver (sources ));
89+ 		resolvers .add (new  PropertySourcesPropertyResolver (createNullDefaultSources (environment , sourceClass )));
90+ 		resolvers .add (new  PropertySourcesPropertyResolver (createEmptyDefaultSources (sourceClass )));
9791		return  resolvers ;
9892	}
9993
100- 	private  MapPropertySource  getTitleSource (Class <?> sourceClass ) {
94+ 	private  MutablePropertySources  createNullDefaultSources (Environment  environment , Class <?> sourceClass ) {
95+ 		MutablePropertySources  nullDefaultSources  = new  MutablePropertySources ();
96+ 		if  (environment  instanceof  ConfigurableEnvironment  configurableEnvironment ) {
97+ 			configurableEnvironment .getPropertySources ().forEach (nullDefaultSources ::addLast );
98+ 		}
99+ 		nullDefaultSources .addLast (getTitleSource (sourceClass , null ));
100+ 		nullDefaultSources .addLast (getAnsiSource ());
101+ 		nullDefaultSources .addLast (getVersionSource (sourceClass , null ));
102+ 		return  nullDefaultSources ;
103+ 	}
104+ 
105+ 	private  MutablePropertySources  createEmptyDefaultSources (Class <?> sourceClass ) {
106+ 		MutablePropertySources  emptyDefaultSources  = new  MutablePropertySources ();
107+ 		emptyDefaultSources .addLast (getTitleSource (sourceClass , "" ));
108+ 		emptyDefaultSources .addLast (getVersionSource (sourceClass , "" ));
109+ 		return  emptyDefaultSources ;
110+ 	}
111+ 
112+ 	private  MapPropertySource  getTitleSource (Class <?> sourceClass , String  defaultValue ) {
101113		String  applicationTitle  = getApplicationTitle (sourceClass );
102114		Map <String , Object > titleMap  = Collections .singletonMap ("application.title" ,
103- 				(applicationTitle  != null ) ? applicationTitle  : "" );
115+ 				(applicationTitle  != null ) ? applicationTitle  : defaultValue );
104116		return  new  MapPropertySource ("title" , titleMap );
105117	}
106118
@@ -119,18 +131,18 @@ private AnsiPropertySource getAnsiSource() {
119131		return  new  AnsiPropertySource ("ansi" , true );
120132	}
121133
122- 	private  MapPropertySource  getVersionSource (Class <?> sourceClass ) {
123- 		return  new  MapPropertySource ("version" , getVersionsMap (sourceClass ));
134+ 	private  MapPropertySource  getVersionSource (Class <?> sourceClass ,  String   defaultValue ) {
135+ 		return  new  MapPropertySource ("version" , getVersionsMap (sourceClass ,  defaultValue ));
124136	}
125137
126- 	private  Map <String , Object > getVersionsMap (Class <?> sourceClass ) {
138+ 	private  Map <String , Object > getVersionsMap (Class <?> sourceClass ,  String   defaultValue ) {
127139		String  appVersion  = getApplicationVersion (sourceClass );
128140		String  bootVersion  = getBootVersion ();
129141		Map <String , Object > versions  = new  HashMap <>();
130- 		versions .put ("application.version" , getVersionString (appVersion , false ));
131- 		versions .put ("spring-boot.version" , getVersionString (bootVersion , false ));
132- 		versions .put ("application.formatted-version" , getVersionString (appVersion , true ));
133- 		versions .put ("spring-boot.formatted-version" , getVersionString (bootVersion , true ));
142+ 		versions .put ("application.version" , getVersionString (appVersion , false ,  defaultValue ));
143+ 		versions .put ("spring-boot.version" , getVersionString (bootVersion , false ,  defaultValue ));
144+ 		versions .put ("application.formatted-version" , getVersionString (appVersion , true ,  defaultValue ));
145+ 		versions .put ("spring-boot.formatted-version" , getVersionString (bootVersion , true ,  defaultValue ));
134146		return  versions ;
135147	}
136148
@@ -143,9 +155,9 @@ protected String getBootVersion() {
143155		return  SpringBootVersion .getVersion ();
144156	}
145157
146- 	private  String  getVersionString (String  version , boolean  format ) {
158+ 	private  String  getVersionString (String  version , boolean  format ,  String   fallback ) {
147159		if  (version  == null ) {
148- 			return  "" ;
160+ 			return  fallback ;
149161		}
150162		return  format  ? " (v"  + version  + ")"  : version ;
151163	}
0 commit comments