We had an issue during automatic delivery through another platform where we found that some properties were modified and the 3rd party system added an whitespace at the end of a property.

Of course this was a problem of the other system, BUT, would it be possible to trim the whitespaces at the end of each property in order to avoid these scenarios? Or add a spring property that would activate this option?

Error for reference:


Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [com.hiddendasitisprivate.config.CustomOracleDialect ]
   at 
org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:133) ~[hibernate-core-5.4.9.Final.jar:5.4.9.Final]
   at 
org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:129) ~[hibernate-core-5.4.9.Final.jar:5.4.9.Final]
   ... 56 common frames omitted

Caused by: java.lang.ClassNotFoundException: Could not load requested class : com.hiddendasitisprivate.config.CustomOracleDialect

Comment From: snicoll

@hashdava thanks for the suggestion. This was already requested and declined, see #4106

Comment From: hdava

@snicoll sorry, but I don't think this ticket should be closed.

I had suggested a way to let the user to opt for this trim. The user could set an additional spring property to trim the properties or not - this would be dynamic.

The explanation that this change could not be applied because there is not "safe" way to do this because the space might be added on purpose by the user it's understandable, BUT, it would be great to have an additional property that would allow the user to specifically say that the properties should be trim.

Please let me know your thoughts.

Comment From: snicoll

Such property would have to be read very early on to make sure the content of the Environment is consistent with whatever we do at runtime. System properties and environment variables are read right when the environment is created so we'd have to look it up there before that.

Sorry but that's a lot of complexity for something you can configure in your own editor as hinted in the issue that I referenced.

Comment From: hdava

I'm just going to give it a try 😊

https://github.com/hashdava/spring-boot