You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by "Tran Hong Quan (Jira)" <se...@james.apache.org> on 2022/09/07 08:00:00 UTC

[jira] [Created] (JAMES-3815) Handle possible null case (as optional) in imapUidTable and messageIdTable

Tran Hong Quan created JAMES-3815:
-------------------------------------

             Summary: Handle possible null case (as optional) in imapUidTable and messageIdTable
                 Key: JAMES-3815
                 URL: https://issues.apache.org/jira/browse/JAMES-3815
             Project: James Server
          Issue Type: Bug
    Affects Versions: master
            Reporter: Tran Hong Quan


We observed a NullPointerException in our staging env:

```

{"timestamp":"2022-09-06T03:08:52.653Z","level":"ERROR","thread":"s1-io-2","mdc":\{"protocol":"JMAP","ip":"10.2.1.28","real-ip":"51.68.40.116"},"logger":"org.apache.james.jmap.http.JMAPApiRoutes","message":"Unexpected error","context":"default","exception":"java.lang.NullPointerException: Cannot invoke "java.time.Instant.toEpochMilli()" because "" is null\n\tat java.base/java.util.Date.from(Unknown Source)\n\tat org.apache.james.mailbox.cassandra.mail.CassandraMessageIdToImapUidDAO.toComposedMessageIdWithMetadata(CassandraMessageIdToImapUidDAO.java:406)...

```

 

This NPE likely comes from badly applied [Rework message denormalization migration]([https://github.com/apache/james-project/blob/master/upgrade-instructions.md#rework-message-denormalization)] which creates in `imapUidTable` and `messageIdTable` a few rows with null `internalDate`, `bodyStartOctet`, `fullContentOctets` and `headerContent`.

 

Now the Cassandra driver 4 code just triggers that NPE (can not convert a null to Date), the old driver code accepts null though (ComposedMessageIdWithMetaData.builder():: 

internalDate accepts null).

 

We anticipate others could have a bad migration leading to this NPE as well, therefore we need to handle this possible null value in `messageIdTable` and `imapUidTable` using Optional.

 

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org