[ 
https://issues.apache.org/jira/browse/GERONIMO-6852?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Richard Zowalla closed GERONIMO-6852.
-------------------------------------
    Resolution: Invalid

This is not a Geronimo Mail issue. The default DataContentHandler chain - 
including the fallback that handles application/octet-stream as a 
byte[]/InputStream - lives in the Jakarta Activation implementation, not in the 
Mail implementation.

This repository (geronimo-mail) ships jakarta.mail only: the spec module and 
the provider. It contains no jakarta.activation implementation, and neither of 
the two META-INF/mailcap files registers a handler for 
application/octet-stream, by design - mailcap only covers the types Mail itself 
has to understand (text/plain, text/html, text/xml, multipart/*, 
message/rfc822).

The behaviour change between TomEE 8.0.15 and 9.1.0 comes from the 
jakarta.activation implementation bundled in jakartaee-api-9.1.1-tomcat.jar. 
Please re-open against TomEE, or against Eclipse Angus Activation, whichever 
turns out to be shipping the incomplete activation implementation.

Closing as Invalid for this project.

> No default DataContentHandler like ObjectDataContentHandler present inside 
> jakartaee-api-9.1.1-tomcat.jar of tomee 9.1.0
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GERONIMO-6852
>                 URL: https://issues.apache.org/jira/browse/GERONIMO-6852
>             Project: Geronimo
>          Issue Type: Bug
>      Security Level: public(Regular issues) 
>          Components: general
>            Reporter: Dharmraj Gocher
>            Priority: Major
>
>  In jakartaee-api-9.1.1-tomcat.jar of tomee 9.1.0, we could see a new package 
> jakarta.activation introduced which contains classes like 
> jakarta.activation.DataHandler.class etc. which were present in 
> jakarta.activation.jar earlier in tomee 8.0.15 but not in 
> javaee-api-8.0-6-tomcat.jar. 
> The implementation for jakarta.activation.DataHandler inside  
> jakartaee-api-9.1.1-tomcat.jar does not have any default DataContentHandler. 
>  
> The below code used to work until tomee 8.0.15
>  
> {code:java}
> String attachment = "Some base 64 encoded content";
> MimeBodyPart emailAttachment = new MimeBodyPart();
> emailAttachment.setContent(Base64.getMimeDecoder().decode(attachment), 
> "application/octet-stream");
> {code}
>  
>  
> The above same code is failing in tomee 9.1.0 with error -
> *ERROR-*
> Caused by: jakarta.activation.UnsupportedDataTypeException: 
> application/octet-stream
> at jakarta.activation.DataHandler.writeTo(DataHandler.java:75)
> at jakarta.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:489)
> at jakarta.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:255)
> at 
> org.apache.geronimo.mail.handlers.MultipartHandler.writeTo(MultipartHandler.java:57)
> at jakarta.activation.DataHandler.writeTo(DataHandler.java:77)
> at jakarta.mail.internet.MimeMessage.writeTo(MimeMessage.java:1287)
> at jakarta.mail.internet.MimeMessage.writeTo(MimeMessage.java:1256)
>  
> Instead of making mandatory to pass DataContentHandler can we provide some 
> default handler like ObjectDataContentHandler similar to jakarta 
> activation.jar? This ensures backward compatibility.
> Something like -
> {code:java}
>       private synchronized DataContentHandler getDataContentHandler() {
>               Class var2 = DataHandler.class;      
>               DataContentHandlerFactory localFactory;      
>               synchronized(DataHandler.class) {
>                       if (factory != this.originalFactory) {
>                               this.dch = null;
>                               this.originalFactory = factory;
>                               }
>                       localFactory = this.originalFactory;
>                       }
>               if (this.dch == null) {
>               String mimeType = this.getMimeType(this.ds.getContentType());
>               if (localFactory != null) {
>          this.dch = localFactory.createDataContentHandler(mimeType);
>                }
>               if (this.dch == null) {
>                       if (this.commandMap != null) {
>                               this.dch = 
> this.commandMap.createDataContentHandler(mimeType);
>                       } else {
>                               this.dch = 
> CommandMap.getDefaultCommandMap().createDataContentHandler(mimeType);
>                       }         
>               }
>                }
>                  if(this.dch == null){
>                           this.dch = <Some default data handler>;
>                  }
>                  return this.dch;
>               }
> {code}



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

Reply via email to