-
Notifications
You must be signed in to change notification settings - Fork 786
Description
Using the API to add a project foo, then renaming the project to Foo, adding it using the same API and defining a project group with pattern ^Foo
, my webapp instance ended up with the group being empty. The resulting serialized configuration had both projects, however the project group had no projects.
Debugging the issue: when RuntimeEnvironment#populateGroups()
was called:
opengrok/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/RuntimeEnvironment.java
Line 1645 in dcf1091
populateGroups(getGroups(), new TreeSet<>(getProjects().values())); |
getProjects().values()
had one extra entry compared to the resulting TreeSet
. That extra entry was the project with name starting with upper case letter, which means the TreeSet
contained just the project with lower case letter and thus not matched by the project group regexp. This is because Project#equals()
method converts the project name to upper case and performs the comparison of the names: opengrok/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Project.java
Lines 614 to 615 in dcf1091
return name.toUpperCase(Locale.ROOT).equals( | |
other.name.toUpperCase(Locale.ROOT)); |
The problem is that ProjectsController#addProject()
(which handles the above mentioned API call) ignores this project name comparison requirement:
opengrok/opengrok-web/src/main/java/org/opengrok/web/api/v1/controller/ProjectsController.java
Line 121 in dcf1091
env.getProjects().put(projectName, project); |
Activity
[-]Project case sensitivity confusion with ProjectsController[/-][+]Project name case sensitivity confusion with ProjectsController[/+]vladak commentedon Jul 27, 2022
The upper case based comparison is not really baked into the code that deals with Project map
projects
inConfiguration
which makes this difficult to fix - either make sure that each key addition to the map respects the comparator or introduce new class (sayProjectName
) that would contain the comparator logic, however that would changeConfiguration
serialization since the project map is stored there.Another alternative would be to remove the upper case based comparison. It was introduced with project groups (d470e59) and it is not clear to me and I don't remember what was the intention @tulinkry. The
Group
comparator also uses this approach.make Project/Group comparison case sensitive
make Project/Group comparison case sensitive (oracle#4017)