Today i was bitten by system case insensitivity twice:
- Maven test does not pick up Spring boot test profile properties
- git commit does not get the file name change.
Spring boot profile based config
In spring boot, we can have different resource files(
.yml ) to hold properties. More over, we could have profile specific ones, like
application-dev.yml will be loaded if
dev is in the ActiveProfiles.
In our project, I passed in
TEST as profile when doing junit test and the resource file name happens to be
application-test.yml. Things work prefect in my local(OSX) as well as my colleagues(Windows). However when we do our CI build in a Docker container which has CentOS, I get exceptions for database url which is environment specific is not loaded. Spent more than 1 hour working with our CM to figure this out. So I changed test profile name to
test and it worked.
git commit ignore file name case change
I was trying to change a class name from
ReportDaoTest but after check in, CI build failed again since only the class name changed but the file name remains the same.
GIT is case-sensitive but some file systems, like HFS, are not. Git can’t detect your changes, because the file names didn’t change really.
The two most popular operating systems that have case-insensitive file systems that I know of are
- OS X
So to fix this, we can do either:
git mv -f OldFileNameCase newfilenamecase
- git config –global core.ignorecase false
For this SO question.
A good lesson. Previously never thought about this could cause trouble. I was thing it was char encoding problem and turns out not.