camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Camel Mail issue with unsupported charset
Date Sun, 08 Nov 2009 11:25:46 GMT
On Sun, Nov 8, 2009 at 9:38 AM, dcheckoway <dcheckoway@gmail.com> wrote:
>
> Sorry, I haven't yet.  I've been bogged with other stuff and haven't even
> looked into how to build camel from source...excuses, excuses.  I hope to
> get around to it in the next week or so and will definitely let you know!
>

Hi

I have attached a .jar with a fix I have just coded. Can you test it
on your system.
The commit is rev 833857.

> Thanks,
> Dan
>
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> Did you try with this code and did it work for you?
>>
>>
>> On Thu, Nov 5, 2009 at 12:50 AM, dcheckoway <dcheckoway@gmail.com> wrote:
>>>
>>> Claus, I'm not a contributor on the Camel project, but here's what I
>>> would
>>> advocate trying in MailBinding.java, expanding the meaning of
>>> "ignoreUnsupportedCharset" a bit:
>>>
>>>    public Object extractBodyFromMail(Exchange exchange, Message message)
>>> {
>>>        return extractBodyFromMail(exchange, message, false);
>>>    }
>>>
>>>    private Object extractBodyFromMail(Exchange exchange, Message message,
>>> boolean isSecondAttempt) {
>>>        try {
>>>            return message.getContent();
>>>        } catch (Exception e) {
>>>            if (!isSecondAttempt &&
>>>                (e instanceof java.io.UnsupportedEncodingException ||
>>>                 (e.getCause() != null &&
>>>                  e.getCause() instanceof
>>> java.io.UnsupportedEncodingException)) &&
>>>                configuration.isIgnoreUnsupportedCharset()) {
>>>                // The charset is unsupported, but we've been configured
>>> to
>>>                // ingore that condition.  Let's at least attempt to
>>> rewrite
>>>                // the Content-Type header and omit the unsupported
>>> charset.
>>>                // This may wreak havoc down the line, but it's better
>>> than
>>>                // Camel just bailing on this exchange, and ending up
>>> retrying
>>>                // this same message over and over, and failing every
>>> time...
>>>                String contentType = message.getContentType();
>>>                if (contentType != null) {
>>>                    // Wipe out the charset=... from the Content-Type
>>> header
>>>                    contentType =
>>> contentType.replaceAll("\\s*charset=[^;\\s]+", "");
>>>                    part.setHeader("Content-Type", contentType);
>>>                    // Try again...pass isSecondAttempt=true this time
>>>                    return extractBodyFromMail(exchange, message, true);
>>>                }
>>>            }
>>>            else {
>>>                throw new RuntimeCamelException("Failed to extract body
>>> due
>>> to: " + e.getMessage()
>>>                                                + ". Exchange:
" +
>>> exchange
>>> + ". Message: " + message, e);
>>>            }
>>>        }
>>>    }
>>>
>>> What do you think?
>>>
>>>
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>> On Wed, Nov 4, 2009 at 7:24 PM, dcheckoway <dcheckoway@gmail.com> wrote:
>>>>>
>>>>> Is there any way to "intercept" the raw mail message content before it
>>>>> gets
>>>>> passed to the java mail API?  I would be happy to manually munge the
>>>>> Content-Type header if I detect one of the known-to-be-funky charsets
>>>>> in
>>>>> there.
>>>>>
>>>>
>>>> You can use a custom MailBinding class, e.g. extending the on in
>>>> camel-maill.
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Camel-Mail-issue-with-unsupported-charset-tp24755585p26206832.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Camel-Mail-issue-with-unsupported-charset-tp24755585p26251752.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message