[
https://issues.apache.org/jira/browse/JAMES-1840?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16504141#comment-16504141
]
ASF GitHub Bot commented on JAMES-1840:
---------------------------------------
Github user chibenwa commented on a diff in the pull request:
https://github.com/apache/james-project/pull/117#discussion_r193606775
--- Diff:
mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/DefaultQuotaRootResolver.java
---
@@ -55,6 +55,7 @@ public QuotaRoot createQuotaRoot(String quotaRootValue) {
@Override
public QuotaRoot getQuotaRoot(MailboxPath mailboxPath) throws
MailboxException {
Preconditions.checkArgument(!mailboxPath.getNamespace().contains(SEPARATOR),
"Namespace should not contain " + SEPARATOR);
+ Preconditions.checkArgument(mailboxPath.getUser() != null,
"Username should not be null");
--- End diff --
Hi Edgar.
Thank you very much for your contribution.
However, I don't think solving this issue is that easy... `null` user of a
mailboxpath had been used for shared folders thus I think we should consider it
as valid.
What would you thing of this:
```
MailboxPath("#namespace", "user", "any) -> QuotaRoot will be
"#namespace&user"
MailboxPath("#namespace", null, "any) -> QuotaRoot will be "#namespace"
```
(We just ignore the user part of the quota root when none).
Of course, we would need to better represent the fact that a mailbox path
might not have a user (by using Optional?) but that is a long refactoring on a
central object that would introduce API breaking changes, hence the former
solution seems better to me.
Best regards,
Benoit
> NPE on quota update when performed with null user
> -------------------------------------------------
>
> Key: JAMES-1840
> URL: https://issues.apache.org/jira/browse/JAMES-1840
> Project: James Server
> Issue Type: Bug
> Components: mailbox
> Reporter: Tellier Benoit
> Priority: Major
> Labels: easyfix
>
> When using a null user on a mailbox path...
> {code:java}
> java.lang.NullPointerException: null
> at
> DefaultQuotaRootResolver.getQuotaRoot(DefaultQuotaRootResolver.java:58)
> at
> ListeningCurrentQuotaUpdater.event(ListeningCurrentQuotaUpdater.java:59)
> at createMailbox(StoreMailboxManager.java:474)
> {code}
> Answer *DefaultQuotaRootResolver* accepts mailboxPaths with null users. Also
> add test cases regarding this in *DefaultQuotaRootResolverTest*.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]