Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mail] fix thing actions not available from UI #254

Merged
merged 1 commit into from
Dec 28, 2021

Conversation

J-N-K
Copy link
Member

@J-N-K J-N-K commented Dec 24, 2021

Reported on the forum. The reason is that the standard implementation uses a context class loader to get the mime type handlers and tries to load the handlers from there. Under some circumstances this is the class loader of the activation bundle which does doesn't have the com.sun.mail packages available, leading to an javax.activation.UnsupportedDataTypeException: text/plain; charset=UTF-8 exception.

Signed-off-by: Jan N. Klug jan.n.klug@rub.de

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
@J-N-K J-N-K added the bug Something isn't working label Dec 24, 2021
@J-N-K J-N-K added this to the 3.1.9 milestone Dec 24, 2021
@J-N-K J-N-K requested a review from cweitkamp December 24, 2021 21:36
@cweitkamp
Copy link
Contributor

I am not sure if I understand the root cause for sure. What I can tell you is that I did not see a similar exception when using Jython scripting. Do you think it only occurs when using JS scripting?

Can it be related to openhab/openhab-addons#11400?

@J-N-K
Copy link
Member Author

J-N-K commented Dec 27, 2021

Not sure but since it also affects DSL rules (and only UI, not file-base rules) I doubt it.

The problem is that javax.activation contains the MailcapCommandMap which is used to select a mail-handler when sending a mail. When creating the object, it tries to load the required data via classloaders of several bundles. One of these bundles is com.sun.mail/javax.mail/1.6.2. Later, when sending the mail, a class name is looked up in the map (for the content-type) and the current threads ContextClassloader is used to load that class via reflection. It seems that in our case for UI defines rules the ContextClassloader doesn't contain the classes from com.sun.mail/javax.mail/1.6.2.

Since it worked before, it could also be that this is a result of the transition from org.apache.servicemix.specs/org.apache.servicemix.specs.activation-api-1.1/2.9.0 to org.apache.servicemix.specs/org.apache.servicemix.specs.activation-api-1.2.1/1.2.1_3 (even if the implementations looks the same for both versions).

Copy link
Contributor

@cweitkamp cweitkamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, let's give it a try.

May add some comments to the patched class to mark the changes as a reminder for later.

@J-N-K
Copy link
Member Author

J-N-K commented Dec 28, 2021

I added a "Changelog" to the file header

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants