[ 
https://issues.apache.org/jira/browse/JAMES-3828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17611330#comment-17611330
 ] 

Benoit Tellier commented on JAMES-3828:
---------------------------------------

Interesting bit about that one is that the Attributes being un-serialisable, 
the error was basically un-manageable.

 - Cannot requeue while tracking failure count as attributes could not be 
serialised
 - Cannot store it in a mail repository (attribute serialization still failing)

Thus the spooler was doing a NACK that effectively requeued the poisonnous 
message, resulting in an infinite loop.

I do belive that we should give the grammar for the Spooler to REJECT 
poisonnous mails, underlying implementations could then handle this rejection. 
In the Rabbit/Pulsar case, a dead letter topic sounds like the way to go. 
(that's a good thing that we have healthchecks for it!)

I propose an evolution of `MailQueueItem` interface:


{code:java}
interface MailQueueItem {
    enum CompletionStatus {
        SUCCESS,
        RETRY,
        REJECT
    }

    /**
     * Return the dequeued {@link Mail}
     * 
     * @return mail
     */
    Mail getMail();

    /**
     * Callback which MUST get called after the operation on the dequeued
     * {@link Mail} was complete.
     * 
     * This is mostly used to either commit a transaction or rollback.
     * 
     * @param success
     * @throws MailQueueException
     */
    void done(CompletionStatus success) throws MailQueueException;
}{code}
 

 

> ava.lang.ClassCastException: class [B cannot be cast to class 
> org.apache.mailet.AttributeValue ([B is in module java.base of loader 
> 'bootstrap'; org.apache.mailet.AttributeValue is in unnamed module of loader 
> 'app')
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: JAMES-3828
>                 URL: https://issues.apache.org/jira/browse/JAMES-3828
>             Project: James Server
>          Issue Type: Bug
>          Components: Mailet Contributions
>    Affects Versions: master
>            Reporter: Benoit Tellier
>            Priority: Major
>             Fix For: 3.8.0
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Got the following error today
> {code:java}
> exception     java.lang.ClassCastException: class [B cannot be cast to class 
> org.apache.mailet.AttributeValue ([B is in module java.base of loader 
> 'bootstrap'; org.apache.mailet.AttributeValue is in unnamed module of loader 
> 'app')
>  at 
> org.apache.mailet.Serializer$MapSerializer.lambda$serialize$0(Serializer.java:507)
>   at 
> com.google.common.collect.CollectCollectors.lambda$toImmutableMap$6(CollectCollectors.java:185)
>    at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(Unknown 
> Source)
>     at 
> java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown 
> Source)
>      at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
>       at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown 
> Source)
>        at 
> java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown 
> Source)
>         at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown 
> Source)
>          at java.base/java.util.stream.ReferencePipeline.collect(Unknown 
> Source)
>           at 
> org.apache.mailet.Serializer$MapSerializer.serialize(Serializer.java:507)
>            at 
> org.apache.mailet.Serializer$MapSerializer.serialize(Serializer.java:503)
>             at 
> org.apache.mailet.AttributeValue.toJson(AttributeValue.java:256)
>              at 
> org.apache.mailet.AttributeValue.duplicate(AttributeValue.java:250)
>               at org.apache.mailet.Attribute.duplicate(Attribute.java:62)
>                at 
> java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
>                 at 
> java.base/java.util.HashMap$ValueSpliterator.forEachRemaining(Unknown Source)
>                  at 
> java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
>                   at 
> java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
>                    at 
> java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown 
> Source)
>                     at 
> java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
>                      at 
> java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
>                       at 
> org.apache.james.server.core.MailImpl.duplicateAttributes(MailImpl.java:117)
>                        at 
> org.apache.james.server.core.MailImpl.duplicateWithoutMessage(MailImpl.java:111)
>                         at 
> org.apache.james.server.core.MailImpl.duplicate(MailImpl.java:97)
>                          at 
> org.apache.james.mailetcontainer.impl.MatcherSplitter.split(MatcherSplitter.java:149)
>                           at 
> org.apache.james.mailetcontainer.impl.MailetProcessorImpl.lambda$executeProcessingStep$3(MailetProcessorImpl.java:158)
> {code}
> The postmortem is that for XYZ reason, we ingested a Map that do not have the 
> good actual types thus we fail serializing the associate attribute. This 
> prevent us from duplicating the attributes and causes the mail not to be 
> split, thus aborting mail processing.
> We do not know where invalid data was first generated.
> That's weaknesses of the Java parameter type systems.
> We shall:
>  - Avoid serializing / deserializing attributes to duplicate them and instead 
> do something smarter
>  - Reject invalid collections/bad type parameters as early as possible.
> This is potentially due to a custom extension.



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

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

Reply via email to