[ https://issues.apache.org/jira/browse/CAMEL-13560?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16850091#comment-16850091 ]
Kamil commented on CAMEL-13560: ------------------------------- [~ffang] - Great! Here is the bundle that reproduces the issue: {code:java} package karaf.mail.issue; import static java.util.Objects.nonNull; import java.util.Map; import java.util.UUID; import javax.activation.DataHandler; import org.apache.camel.Attachment; import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.Message; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.core.osgi.OsgiDefaultCamelContext; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class Activator implements BundleActivator { private static final Logger log = LoggerFactory.getLogger(Activator.class); private static final String HOST = "<TYPE_HOST>"; private static final String LOGIN = "<TYPE_LOGIN>"; private static final String PASSWORD = "<TYPE_PASSWORD>"; private static final int PORT = 993; private ServiceRegistration<CamelContext> registrationCamelContext; private CamelContext camelContext; @Override public void start(final BundleContext bundleContext) throws Exception { log.info("Registering OsgiDefaultCamelContext"); camelContext = new OsgiDefaultCamelContext(bundleContext); registrationCamelContext = bundleContext.registerService(CamelContext.class, camelContext, null); final EmailRoute emailRoute = new EmailRoute(camelContext); camelContext.addRoutes(emailRoute); camelContext.start(); } @Override public void stop(BundleContext context) throws Exception { log.info("Unregistering OsgiDefaultCamelContext"); if(nonNull(registrationCamelContext)) { registrationCamelContext.unregister(); } if(nonNull(camelContext)) { camelContext.stop(); } } public class EmailRoute extends RouteBuilder { private static final String ROUTE_FROM = "imaps:/"; private final String routeId; public EmailRoute(final CamelContext camelContext) throws Exception { super(camelContext); this.routeId = UUID.randomUUID().toString(); } @Override public void configure() throws Exception { from(String.format("%s/%s@%s:%s?password=%s&debugMode=false&delete=false&unseen=true&consumer.delay=30000", ROUTE_FROM, LOGIN, HOST, PORT, PASSWORD)) .routeId(routeId) .process(new Processor() { @Override public void process(final Exchange exchange) throws Exception { final Message in = exchange.getIn(); final String from = in.getHeader("from", String.class); final String subject = in.getHeader("subject", String.class); log.info("Processing email from: {}, with subject: {}", from, subject); final Map<String, Attachment> objects = in.getAttachmentObjects(); log.debug("getAttachmentObjects: {}", objects); final Object body = in.getBody(); log.info("Body: {}", body); final Map<String, DataHandler> attachments = in.getAttachments(); log.info("ATTACHMENTS FOUND: {}", attachments.size()); } }); } } } {code} If you want to deploy using bnd - here it is: {code:java} Private-Package: karaf.mail.issue Bundle-Version: 1.0.0 Bundle-Activator: karaf.mail.issue.Activator Bundle-Name: Karaf mail test Bundle-Description: Trying to reproduce bug -runee: JavaSE-1.8 -runproperties: \ org.osgi.framework.bootdelegation="sun.misc" -buildpath: \ slf4j.api;version=1.7,\ osgi.core;version=6.0,\ osgi.annotation;version=6.0,\ org.apache.camel.camel-core;version=2.23,\ org.apache.camel.camel-core-osgi;version=2.23,\ org.apache.camel.camel-mail;version=2.23,\ com.sun.mail.javax.mail;version=1.6,\ javax.activation:activation;version=1.1 -runrequires: \ bnd.identity;id='org.apache.camel.camel-core-osgi',\ bnd.identity;id='org.apache.camel.camel-mail',\ bnd.identity;id='com.sun.mail.javax.mail' -runbundles: \ ch.qos.logback.classic;version='[1.2.3,1.2.4)',\ ch.qos.logback.core;version='[1.2.3,1.2.4)',\ com.sun.mail.javax.mail;version='[1.6.1,1.6.2)',\ org.apache.camel.camel-core;version='[2.23.1,2.23.2)',\ org.apache.camel.camel-core-osgi;version='[2.23.1,2.23.2)',\ org.apache.camel.camel-mail;version='[2.23.1,2.23.2)',\ org.osgi.service.event;version='[1.4.0,1.4.1)',\ slf4j.api;version='[1.7.25,1.7.26)' {code} Environment: * Windows 7 * Gitbash * apache-karaf-4.2.5 * JDK8 (working): java version "1.8.0_144" / Java(TM) SE Runtime Environment (build 1.8.0_144-b01) / Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode) * JDK11 (not working): openjdk version "11.0.2" 2019-01-15 / OpenJDK Runtime Environment 18.9 (build 11.0.2+9) / OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode) Steps to reproduce: 1) Set host / user / password in java file 2) Build bundle 3) Clean version of Karaf (rm -fr data) 4) feature:repo-add camel 2.23.1 5) feature:install camel camel-scr camel-stream camel-mail 6) bundle:install -s mvn:my.group/karaf.mail.issue/1.0.0 7) log:tail 8) send email with attachment (or mark as unread) On JDK8 you get: 21:46:26.204 INFO [Camel (camel-1) thread #1 - imaps://username@host:993] ATTACHMENTS FOUND: 1 On JDK9/11 you get: 21:50:11.103 INFO [Camel (camel-1) thread #1 - imaps://username@host:993] ATTACHMENTS FOUND: 0 > Mail component is not reading attachments in OSGi > ------------------------------------------------- > > Key: CAMEL-13560 > URL: https://issues.apache.org/jira/browse/CAMEL-13560 > Project: Camel > Issue Type: Bug > Components: camel-mail > Affects Versions: 2.24.0 > Reporter: Kamil > Priority: Minor > > I have such route (taken from > [documentation|https://camel.apache.org/mail.html]): > {code:java} > @Override > public void configure() throws Exception { > from("imaps://login@host:993?password=pass&debugMode=true") > .process(new Processor() { > @Override > public void process(final Exchange exchange) throws Exception { > final Message in = exchange.getIn(); > > Map<String, DataHandler> attachments = in.getAttachments(); > System.out.println("ATTACHMENTS: "+attachments.size()); > } > }); > } > {code} > When I sent email with images.jpg attachment, email is read, but attachment > Map is empty. > Debug shows: > {code:java} > DEBUG: setDebug: JavaMail version 1.6.1 > DEBUG: getProvider() returning > javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle,1.6.1] > DEBUG IMAPS: mail.imap.fetchsize: 16384 > DEBUG IMAPS: mail.imap.ignorebodystructuresize: false > DEBUG IMAPS: mail.imap.statuscachetimeout: 1000 > DEBUG IMAPS: mail.imap.appendbuffersize: -1 > DEBUG IMAPS: mail.imap.minidletime: 10 > DEBUG IMAPS: closeFoldersOnStoreFailure > DEBUG IMAPS: trying to connect to host "XXXXXX.com", port 993, isSSL true > * OK IMAP4 ready > A0 CAPABILITY > * CAPABILITY IMAP4rev1 UIDPLUS LITERAL+ CHILDREN NAMESPACE XLIST IDLE MOVE > XAOL-MOVE AUTH=PLAIN > A0 OK completed > DEBUG IMAPS: AUTH: PLAIN > DEBUG IMAPS: protocolConnect login, host=XXXXXX.com, user=XXXXXXX, > password=<non-null> > DEBUG IMAPS: AUTHENTICATE PLAIN command trace suppressed > DEBUG IMAPS: AUTHENTICATE PLAIN command result: A1 OK Login completed > A2 CAPABILITY > * CAPABILITY IMAP4rev1 UIDPLUS LITERAL+ CHILDREN NAMESPACE XLIST ID IDLE MOVE > XAOL-MOVE > A2 OK CAPABILITY completed > A3 LIST "" INBOX > * LIST (\Noinferiors) "/" "INBOX" > A3 OK List completed > DEBUG IMAPS: connection available -- size: 1 > A4 SELECT INBOX > * 13 EXISTS > * 0 RECENT > * OK [UNSEEN 13] UIDs valid > * OK [UIDVALIDITY 1549376878] UIDs valid > * OK [UIDNEXT 36] Predicted next UID > * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) > * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft)] > * OK [NOMODSEQ] Sorry, this mailbox format doesn't support modsequences > A4 OK [READ-WRITE] SELECT completed > A5 SEARCH UNSEEN 1:13 > * SEARCH 13 > A5 OK Search completed > A6 FETCH 13 (BODY.PEEK[HEADER.FIELDS (Message-ID)]) > * 13 FETCH (BODY[HEADER.FIELDS (Message-ID)] {65} > Message-ID: <175c8cc9-19fa-fc48-40c8-e42148578...@xxxxxx.com> > ) > A6 OK Fetch completed > A7 FETCH 13 (FLAGS) > * 13 FETCH (FLAGS ()) > A7 OK Fetch completed > A8 FETCH 13 (BODYSTRUCTURE) > * 13 FETCH (BODYSTRUCTURE (("text" "plain" ("charset" "utf-8" "format" > "flowed") NIL NIL "7bit" 10 3 NIL NIL NIL)("image" "jpeg" ("name" > "images.jpg") NIL NIL "base64" 16794 NIL ("attachment" ("filename" > "images.jpg")) NIL) "mixed" ("boundary" > "------------53A9AD932142735A4433B153") NIL NIL)) > A8 OK Fetch completed > A9 FETCH 13 (BODY.PEEK[HEADER]) > * 13 FETCH (BODY[HEADER] {3286} > Return-Path: <xxx...@xxxxxx.com> > Delivered-To: xxx...@xxxxxx.com > Received: (wp-smtpd mx.XXXXXX.com 31103 invoked from network); 22 May 2019 > 16:14:00 +0200 > Received: from mail-XXX.google.com ([209.85.167.54]) > (envelope-sender <xxx...@xxxxxx.com>) > by mx.tlen.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted > SMTP > for <xxx...@xxxxxx.com>; 22 May 2019 16:14:00 +0200 > Received: by mail-XXX.google.com with SMTP id d8so1XXXb.8 > for <xxx...@xxxxxx.com>; Wed, 22 May 2019 07:14:00 -0700 (PDT) > DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; > d=XXX.gappssmtp.com; s=XXX; > h=to:from:subject:message-id:date:user-agent:mime-version > :content-language; > bh=8Bw7uLBuofXm3FHknjhDSjXXX=; > b=kqcK74fTrzyDas7Wsn7EJfSxJuXXX== > X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; > d=1e100.net; s=20161025; > h=x-gm-message-state:to:from:subject:message-id:date:user-agent > :mime-version:content-language; > bh=8Bw7uLBuofXmXXXX6oDyAiCFLfHU=; > b=F1EsLfk3qaiJXiNX0XXXXXXX== > X-Gm-Message-State: APXXXXXX= > X-Google-Smtp-Source: APXvXXXXXWYQ== > X-Received: by 2002:a19:c517:: with SMTP id w23mr27342169lfe.73.1558534439904; > Wed, 22 May 2019 07:13:59 -0700 (PDT) > Return-Path: <xxx...@xxxxxx.com> > Received: from [XXXXXX] (host-XXXXXX.com. [XXXXXX]) > by smtp.gmail.com with ESMTPSA id XXXX > for <xxx...@xxxxxx.com> > (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); > Wed, 22 May 2019 07:13:59 -0700 (PDT) > To: xxx...@xxxxxx.com > From: =?UTF-8?Q?XXX=c5=9bXX?= <xxx...@xxxxxx.com> > Subject: Test attachment > Message-ID: <175c8cc9-xx...@xxxxxx.com> > Date: Wed, 22 May 2019 16:13:58 +0200 > User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 > Thunderbird/60.6.1 > MIME-Version: 1.0 > Content-Type: multipart/mixed; > boundary="------------53A9AD932142735A4433B153" > Content-Language: pl > X-WP-DKIM-Status: good (id: XXXXXX.com.gappssmtp.c) > X-WP-MailID: 3f705f51c9402ad04c3cda34f72497b2 > X-WP-SPAM: NO (U9) 0W0001A [0QMk] > ) > A9 OK Fetch completed > ATTACHMENTS: 0 > {code} > I've check all: imap, imaps, pop3 and pop3s -- This message was sent by Atlassian JIRA (v7.6.3#76005)