Skip to content

Project name case sensitivity confusion with ProjectsController #4006

@vladak

Description

@vladak
Member

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:

populateGroups(getGroups(), new TreeSet<>(getProjects().values()));
, the 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:
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:

Activity

changed the title [-]Project case sensitivity confusion with ProjectsController[/-] [+]Project name case sensitivity confusion with ProjectsController[/+] on Jul 22, 2022
self-assigned this
on Jul 22, 2022
vladak

vladak commented on Jul 27, 2022

@vladak
MemberAuthor

The upper case based comparison is not really baked into the code that deals with Project map projects in Configuration which makes this difficult to fix - either make sure that each key addition to the map respects the comparator or introduce new class (say ProjectName) that would contain the comparator logic, however that would change Configuration 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.

added a commit that references this issue on Jul 29, 2022
eb0f0e6
added a commit that references this issue on Mar 17, 2024
bf515fc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @vladak

      Issue actions

        Project name case sensitivity confusion with ProjectsController · Issue #4006 · oracle/opengrok