{"action":"created","comment":{"url":"https://api.github.com/repos/linagora/james-project/pulls/comments/122889591","pull_request_review_id":45041124,"id":122889591,"diff_hunk":"@@ -0,0 +1,172 @@\n+/****************************************************************\n+ * Licensed to the Apache Software Foundation (ASF) under one   *\n+ * or more contributor license agreements.  See the NOTICE file *\n+ * distributed with this work for additional information        *\n+ * regarding copyright ownership.  The ASF licenses this file   *\n+ * to you under the Apache License, Version 2.0 (the            *\n+ * \"License\"); you may not use this file except in compliance   *\n+ * with the License.  You may obtain a copy of the License at   *\n+ *                                                              *\n+ *   http://www.apache.org/licenses/LICENSE-2.0                 *\n+ *                                                              *\n+ * Unless required by applicable law or agreed to in writing,   *\n+ * software distributed under the License is distributed on an  *\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *\n+ * KIND, either express or implied.  See the License for the    *\n+ * specific language governing permissions and limitations      *\n+ * under the License.                                           *\n+ ****************************************************************/\n+\n+package org.apache.james.imap.processor.base;\n+\n+import static org.assertj.core.api.Assertions.assertThat;\n+import static org.mockito.Matchers.any;\n+import static org.mockito.Matchers.eq;\n+import static org.mockito.Mockito.doAnswer;\n+import static org.mockito.Mockito.mock;\n+import static org.mockito.Mockito.when;\n+\n+import java.util.Date;\n+import java.util.Iterator;\n+import java.util.TreeMap;\n+import java.util.concurrent.ExecutorService;\n+import java.util.concurrent.Executors;\n+import java.util.concurrent.atomic.AtomicInteger;\n+\n+import javax.mail.Flags;\n+\n+import org.apache.james.imap.api.ImapSessionUtils;\n+import org.apache.james.imap.api.process.ImapSession;\n+import org.apache.james.mailbox.MailboxListener;\n+import org.apache.james.mailbox.MailboxManager;\n+import org.apache.james.mailbox.MailboxSession;\n+import org.apache.james.mailbox.MessageManager;\n+import org.apache.james.mailbox.MessageUid;\n+import org.apache.james.mailbox.model.MailboxConstants;\n+import org.apache.james.mailbox.model.MailboxPath;\n+import org.apache.james.mailbox.model.MessageMetaData;\n+import org.apache.james.mailbox.model.SearchQuery;\n+import org.apache.james.mailbox.store.SimpleMessageMetaData;\n+import org.apache.james.mailbox.store.event.EventFactory;\n+import org.apache.james.mailbox.store.mail.model.DefaultMessageId;\n+import org.apache.james.mailbox.store.mail.model.Mailbox;\n+import org.junit.After;\n+import org.junit.Before;\n+import org.junit.Ignore;\n+import org.junit.Test;\n+import org.mockito.invocation.InvocationOnMock;\n+import org.mockito.stubbing.Answer;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import com.google.common.collect.ImmutableList;\n+\n+\n+public class SelectedMailboxImplTest {\n+\n+    private static final Logger LOGGER = LoggerFactory.getLogger(SelectedMailboxImplTest.class);\n+    public static final MessageUid MESSAGE_UID_5 = MessageUid.of(5);\n+\n+    private ExecutorService executorService;\n+    private MailboxManager mailboxManager;\n+    private MessageManager messageManager;\n+    private MailboxPath mailboxPath;\n+    private ImapSession imapSession;\n+    private Mailbox mailbox;\n+\n+    @Before\n+    public void setUp() throws Exception {\n+        executorService = Executors.newFixedThreadPool(1);\n+\n+        mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE, \"tellier@linagora.com\", MailboxConstants.INBOX);\n+        mailboxManager = mock(MailboxManager.class);\n+        messageManager = mock(MessageManager.class);\n+        when(mailboxManager.getMailbox(eq(mailboxPath), any(MailboxSession.class))).thenReturn(messageManager);\n+        when(messageManager.getApplicableFlags(any(MailboxSession.class))).thenReturn(new Flags());\n+        when(messageManager.search(any(SearchQuery.class), any(MailboxSession.class)))\n+            .then(sleepThenSearchAnswer());\n+\n+        imapSession = mock(ImapSession.class);\n+        when(imapSession.getAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY)).thenReturn(mock(MailboxSession.class));\n+\n+        mailbox = mock(Mailbox.class);\n+        when(mailbox.generateAssociatedPath()).thenReturn(mailboxPath);\n+    }\n+\n+    @After\n+    public void tearDown() {\n+        executorService.shutdownNow();\n+    }\n+\n+    @Ignore\n+    @Test\n+    public void concurrentEventShouldNotSkipUidEmmitedDuringInitialization() throws Exception {\n+        final AtomicInteger success = new AtomicInteger(0);\n+        doAnswer(generateEmitEventAnswer(success))\n+            .when(mailboxManager)\n+            .addListener(eq(mailboxPath), any(MailboxListener.class), any(MailboxSession.class));\n+\n+        SelectedMailboxImpl selectedMailbox = new SelectedMailboxImpl(\n+            mailboxManager,\n+            imapSession,\n+            mailboxPath);\n+\n+        assertThat(selectedMailbox.getLastUid().get()).isEqualTo(MESSAGE_UID_5);","path":"protocols/imap/src/test/java/org/apache/james/imap/processor/base/SelectedMailboxImplTest.java","position":112,"original_position":114,"commit_id":"e915de4a38e738d14b264056e168520dc745945f","original_commit_id":"b74db024409fea9edeb84c571eb02e4863391ca6","user":{"login":"mbaechler","id":708318,"avatar_url":"https://avatars1.githubusercontent.com/u/708318?v=3","gravatar_id":"","url":"https://api.github.com/users/mbaechler","html_url":"https://github.com/mbaechler","followers_url":"https://api.github.com/users/mbaechler/followers","following_url":"https://api.github.com/users/mbaechler/following{/other_user}","gists_url":"https://api.github.com/users/mbaechler/gists{/gist_id}","starred_url":"https://api.github.com/users/mbaechler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbaechler/subscriptions","organizations_url":"https://api.github.com/users/mbaechler/orgs","repos_url":"https://api.github.com/users/mbaechler/repos","events_url":"https://api.github.com/users/mbaechler/events{/privacy}","received_events_url":"https://api.github.com/users/mbaechler/received_events","type":"User","site_admin":false},"body":"MESSAGE_UID_5 deserves a better name","created_at":"2017-06-20T06:26:25Z","updated_at":"2017-06-20T06:35:11Z","html_url":"https://github.com/linagora/james-project/pull/852#discussion_r122889591","pull_request_url":"https://api.github.com/repos/linagora/james-project/pulls/852","_links":{"self":{"href":"https://api.github.com/repos/linagora/james-project/pulls/comments/122889591"},"html":{"href":"https://github.com/linagora/james-project/pull/852#discussion_r122889591"},"pull_request":{"href":"https://api.github.com/repos/linagora/james-project/pulls/852"}}},"pull_request":{"url":"https://api.github.com/repos/linagora/james-project/pulls/852","id":126446615,"html_url":"https://github.com/linagora/james-project/pull/852","diff_url":"https://github.com/linagora/james-project/pull/852.diff","patch_url":"https://github.com/linagora/james-project/pull/852.patch","issue_url":"https://api.github.com/repos/linagora/james-project/issues/852","number":852,"state":"open","locked":false,"title":"JAMES-2063 Avoid NPE during SelectedMailboxImpl initialization","user":{"login":"chibenwa","id":6928740,"avatar_url":"https://avatars2.githubusercontent.com/u/6928740?v=3","gravatar_id":"","url":"https://api.github.com/users/chibenwa","html_url":"https://github.com/chibenwa","followers_url":"https://api.github.com/users/chibenwa/followers","following_url":"https://api.github.com/users/chibenwa/following{/other_user}","gists_url":"https://api.github.com/users/chibenwa/gists{/gist_id}","starred_url":"https://api.github.com/users/chibenwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chibenwa/subscriptions","organizations_url":"https://api.github.com/users/chibenwa/orgs","repos_url":"https://api.github.com/users/chibenwa/repos","events_url":"https://api.github.com/users/chibenwa/events{/privacy}","received_events_url":"https://api.github.com/users/chibenwa/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-06-20T04:48:44Z","updated_at":"2017-06-20T06:35:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3fe3de889341cd4ebb14f70d91b93936c60ce241","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/linagora/james-project/pulls/852/commits","review_comments_url":"https://api.github.com/repos/linagora/james-project/pulls/852/comments","review_comment_url":"https://api.github.com/repos/linagora/james-project/pulls/comments{/number}","comments_url":"https://api.github.com/repos/linagora/james-project/issues/852/comments","statuses_url":"https://api.github.com/repos/linagora/james-project/statuses/e915de4a38e738d14b264056e168520dc745945f","head":{"label":"chibenwa:JAMES-2063","ref":"JAMES-2063","sha":"e915de4a38e738d14b264056e168520dc745945f","user":{"login":"chibenwa","id":6928740,"avatar_url":"https://avatars2.githubusercontent.com/u/6928740?v=3","gravatar_id":"","url":"https://api.github.com/users/chibenwa","html_url":"https://github.com/chibenwa","followers_url":"https://api.github.com/users/chibenwa/followers","following_url":"https://api.github.com/users/chibenwa/following{/other_user}","gists_url":"https://api.github.com/users/chibenwa/gists{/gist_id}","starred_url":"https://api.github.com/users/chibenwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chibenwa/subscriptions","organizations_url":"https://api.github.com/users/chibenwa/orgs","repos_url":"https://api.github.com/users/chibenwa/repos","events_url":"https://api.github.com/users/chibenwa/events{/privacy}","received_events_url":"https://api.github.com/users/chibenwa/received_events","type":"User","site_admin":false},"repo":{"id":42459504,"name":"james-project","full_name":"chibenwa/james-project","owner":{"login":"chibenwa","id":6928740,"avatar_url":"https://avatars2.githubusercontent.com/u/6928740?v=3","gravatar_id":"","url":"https://api.github.com/users/chibenwa","html_url":"https://github.com/chibenwa","followers_url":"https://api.github.com/users/chibenwa/followers","following_url":"https://api.github.com/users/chibenwa/following{/other_user}","gists_url":"https://api.github.com/users/chibenwa/gists{/gist_id}","starred_url":"https://api.github.com/users/chibenwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chibenwa/subscriptions","organizations_url":"https://api.github.com/users/chibenwa/orgs","repos_url":"https://api.github.com/users/chibenwa/repos","events_url":"https://api.github.com/users/chibenwa/events{/privacy}","received_events_url":"https://api.github.com/users/chibenwa/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chibenwa/james-project","description":"Mirror of Apache James Project","fork":true,"url":"https://api.github.com/repos/chibenwa/james-project","forks_url":"https://api.github.com/repos/chibenwa/james-project/forks","keys_url":"https://api.github.com/repos/chibenwa/james-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chibenwa/james-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chibenwa/james-project/teams","hooks_url":"https://api.github.com/repos/chibenwa/james-project/hooks","issue_events_url":"https://api.github.com/repos/chibenwa/james-project/issues/events{/number}","events_url":"https://api.github.com/repos/chibenwa/james-project/events","assignees_url":"https://api.github.com/repos/chibenwa/james-project/assignees{/user}","branches_url":"https://api.github.com/repos/chibenwa/james-project/branches{/branch}","tags_url":"https://api.github.com/repos/chibenwa/james-project/tags","blobs_url":"https://api.github.com/repos/chibenwa/james-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chibenwa/james-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chibenwa/james-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/chibenwa/james-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chibenwa/james-project/statuses/{sha}","languages_url":"https://api.github.com/repos/chibenwa/james-project/languages","stargazers_url":"https://api.github.com/repos/chibenwa/james-project/stargazers","contributors_url":"https://api.github.com/repos/chibenwa/james-project/contributors","subscribers_url":"https://api.github.com/repos/chibenwa/james-project/subscribers","subscription_url":"https://api.github.com/repos/chibenwa/james-project/subscription","commits_url":"https://api.github.com/repos/chibenwa/james-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/chibenwa/james-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/chibenwa/james-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/chibenwa/james-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/chibenwa/james-project/contents/{+path}","compare_url":"https://api.github.com/repos/chibenwa/james-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chibenwa/james-project/merges","archive_url":"https://api.github.com/repos/chibenwa/james-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chibenwa/james-project/downloads","issues_url":"https://api.github.com/repos/chibenwa/james-project/issues{/number}","pulls_url":"https://api.github.com/repos/chibenwa/james-project/pulls{/number}","milestones_url":"https://api.github.com/repos/chibenwa/james-project/milestones{/number}","notifications_url":"https://api.github.com/repos/chibenwa/james-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chibenwa/james-project/labels{/name}","releases_url":"https://api.github.com/repos/chibenwa/james-project/releases{/id}","deployments_url":"https://api.github.com/repos/chibenwa/james-project/deployments","created_at":"2015-09-14T15:57:25Z","updated_at":"2017-02-08T09:35:46Z","pushed_at":"2017-06-20T04:47:47Z","git_url":"git://github.com/chibenwa/james-project.git","ssh_url":"git@github.com:chibenwa/james-project.git","clone_url":"https://github.com/chibenwa/james-project.git","svn_url":"https://github.com/chibenwa/james-project","homepage":null,"size":27644,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":1,"default_branch":"trunk"}},"base":{"label":"linagora:master","ref":"master","sha":"ce408bf8140abc1032987c94912a48e7605e86ba","user":{"login":"linagora","id":1230365,"avatar_url":"https://avatars0.githubusercontent.com/u/1230365?v=3","gravatar_id":"","url":"https://api.github.com/users/linagora","html_url":"https://github.com/linagora","followers_url":"https://api.github.com/users/linagora/followers","following_url":"https://api.github.com/users/linagora/following{/other_user}","gists_url":"https://api.github.com/users/linagora/gists{/gist_id}","starred_url":"https://api.github.com/users/linagora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linagora/subscriptions","organizations_url":"https://api.github.com/users/linagora/orgs","repos_url":"https://api.github.com/users/linagora/repos","events_url":"https://api.github.com/users/linagora/events{/privacy}","received_events_url":"https://api.github.com/users/linagora/received_events","type":"Organization","site_admin":false},"repo":{"id":39182136,"name":"james-project","full_name":"linagora/james-project","owner":{"login":"linagora","id":1230365,"avatar_url":"https://avatars0.githubusercontent.com/u/1230365?v=3","gravatar_id":"","url":"https://api.github.com/users/linagora","html_url":"https://github.com/linagora","followers_url":"https://api.github.com/users/linagora/followers","following_url":"https://api.github.com/users/linagora/following{/other_user}","gists_url":"https://api.github.com/users/linagora/gists{/gist_id}","starred_url":"https://api.github.com/users/linagora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linagora/subscriptions","organizations_url":"https://api.github.com/users/linagora/orgs","repos_url":"https://api.github.com/users/linagora/repos","events_url":"https://api.github.com/users/linagora/events{/privacy}","received_events_url":"https://api.github.com/users/linagora/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/linagora/james-project","description":"Mirror of Apache James Project","fork":true,"url":"https://api.github.com/repos/linagora/james-project","forks_url":"https://api.github.com/repos/linagora/james-project/forks","keys_url":"https://api.github.com/repos/linagora/james-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linagora/james-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linagora/james-project/teams","hooks_url":"https://api.github.com/repos/linagora/james-project/hooks","issue_events_url":"https://api.github.com/repos/linagora/james-project/issues/events{/number}","events_url":"https://api.github.com/repos/linagora/james-project/events","assignees_url":"https://api.github.com/repos/linagora/james-project/assignees{/user}","branches_url":"https://api.github.com/repos/linagora/james-project/branches{/branch}","tags_url":"https://api.github.com/repos/linagora/james-project/tags","blobs_url":"https://api.github.com/repos/linagora/james-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linagora/james-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linagora/james-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/linagora/james-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linagora/james-project/statuses/{sha}","languages_url":"https://api.github.com/repos/linagora/james-project/languages","stargazers_url":"https://api.github.com/repos/linagora/james-project/stargazers","contributors_url":"https://api.github.com/repos/linagora/james-project/contributors","subscribers_url":"https://api.github.com/repos/linagora/james-project/subscribers","subscription_url":"https://api.github.com/repos/linagora/james-project/subscription","commits_url":"https://api.github.com/repos/linagora/james-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/linagora/james-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/linagora/james-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/linagora/james-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/linagora/james-project/contents/{+path}","compare_url":"https://api.github.com/repos/linagora/james-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linagora/james-project/merges","archive_url":"https://api.github.com/repos/linagora/james-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linagora/james-project/downloads","issues_url":"https://api.github.com/repos/linagora/james-project/issues{/number}","pulls_url":"https://api.github.com/repos/linagora/james-project/pulls{/number}","milestones_url":"https://api.github.com/repos/linagora/james-project/milestones{/number}","notifications_url":"https://api.github.com/repos/linagora/james-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linagora/james-project/labels{/name}","releases_url":"https://api.github.com/repos/linagora/james-project/releases{/id}","deployments_url":"https://api.github.com/repos/linagora/james-project/deployments","created_at":"2015-07-16T07:04:59Z","updated_at":"2017-06-10T03:34:42Z","pushed_at":"2017-06-20T04:48:44Z","git_url":"git://github.com/linagora/james-project.git","ssh_url":"git@github.com:linagora/james-project.git","clone_url":"https://github.com/linagora/james-project.git","svn_url":"https://github.com/linagora/james-project","homepage":null,"size":21884,"stargazers_count":9,"watchers_count":9,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":23,"forks":17,"open_issues":23,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/linagora/james-project/pulls/852"},"html":{"href":"https://github.com/linagora/james-project/pull/852"},"issue":{"href":"https://api.github.com/repos/linagora/james-project/issues/852"},"comments":{"href":"https://api.github.com/repos/linagora/james-project/issues/852/comments"},"review_comments":{"href":"https://api.github.com/repos/linagora/james-project/pulls/852/comments"},"review_comment":{"href":"https://api.github.com/repos/linagora/james-project/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/linagora/james-project/pulls/852/commits"},"statuses":{"href":"https://api.github.com/repos/linagora/james-project/statuses/e915de4a38e738d14b264056e168520dc745945f"}}}}
{"actor":{"display_login":"mbaechler"}}