Working around warning log, notification type enum and notification muted
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 564
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 29
Description
Hello Dataverse Team,
I would like to share an analysis with you regarding some specific log (nothing major here ^^) :
[2023-03-16T08:57:09.548+0100] [Payara 5.2022.4] [WARNING] [] [edu.harvard.iq.dataverse.util.BundleUtil] [tid: _ThreadID=177 _ThreadName=http-thread-pool::jk-connector(2)] [timeMillis: 1678953429548] [levelValue: 900] [[
Could not find key "notification.typeDescription.GLOBUSDOWNLOADCOMPLETEDWITHERRORS" in bundle file: ]]
We have the same log with those keys :
notification.typeDescription.GLOBUSDOWNLOADCOMPLETED
notification.typeDescription.GLOBUSDOWNLOADCOMPLETEDWITHERRORS
notification.typeDescription.GLOBUSUPLOADCOMPLETED
notification.typeDescription.GLOBUSUPLOADCOMPLETEDWITHERRORS
In Bundle.properties file it is said that
# Notification types descriptions as presentend to the user. Leave the description empty or leave it out entirely in order to make it not selectable for muting by the user.
Which, in my opinion, is a bit of a strange way to handle "notification to be seen or not".
Checking the java code, UserNotification.hasDescription() seems to be used to "to make it not selectable for muting by the user" :
in DataverseUserPage.init()
notificationTypeList = Arrays.asList(Type.values()).stream()
.filter(x -> !Type.CONFIRMEMAIL.equals(x) && x.hasDescription() && !settingsWrapper.isAlwaysMuted(x))
.collect(Collectors.toList());
This filter make sense but I think we miss this filter when getting the description getDescription() :
in Notifications.getMutedEmailsForUser()
authenticatedUser.getMutedEmails().stream().forEach(
x -> mutedEmails.add(jsonObjectBuilder().add("name", x.name()).add("description", x.getDescription()))
);
or in Notifications.getMutedNotificationsForUser()
authenticatedUser.getMutedNotifications().stream().forEach(
x -> mutedNotifications.add(jsonObjectBuilder().add("name", x.name()).add("description", x.getDescription()))
);
this does trigger the WARNING log to be prompted.
I don't know what is the best way to fix this :
- Adding keys in
Bundle.propertiesand filtering all keys with!Type.GLOBUSDOWNLOADCOMPLETED.equals(x)? - Adding
.filter(x -> x.hasDescription())before ax.getDescription()loop ? - Change
UserNotification.Typeenum style to add a boolean attribut likeallowedToBeMutedByUser = true/falseand use it depending on java code purposes ?
In the meantime I decided to add empty keys in Bundle.properties
notification.typeDescription.GLOBUSDOWNLOADCOMPLETED=
notification.typeDescription.GLOBUSDOWNLOADCOMPLETEDWITHERRORS=
notification.typeDescription.GLOBUSUPLOADCOMPLETED=
notification.typeDescription.GLOBUSUPLOADCOMPLETEDWITHERRORS=
This removes the warnings but if a random person add some value in the future, we will experience issues.
What do you think about it ?
Regards
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with UserNotification.java and compare the hasDescription() handling in DataverseUserPage.java with the muted-email and muted-notification responses in Notifications.java. Review the related entries in Bundle.properties and define consistent behavior for missing descriptions; done means the affected endpoints no longer emit warning logs for these notification types and their mute metadata is correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100