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

Added LoggingAwareExecuter interface to AnnotationBasedActionExecuter… #284

Conversation

tom-vandepoele
Copy link
Contributor

… so exceptions in alfresco actions get handled the same as in ActionExecuterAbstractBase and not throw a java.lang.ClassCastException

Motivation and Context

When Alfresco's ActionServiceImpl method onLogException is called it tries to use the LoggingAwareExecuter interface, however it is not implemented so a java.lang.ClassCastException is thrown instead.
By simply adding the interface to the AnnotationBasedActionExecuter with the same implementation as in ActionExecuterAbstractBase this problem is resolved and error logging is handled as normal in OOTB alfresco action.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the changelog.

@tom-vandepoele
Copy link
Contributor Author

Specifically detected this issue when a mandatory action parameter was not filled in. (triggering the onLogException in the org.alfresco.repo.action.ActionServiceImpl

Very easy to reproduce, just set a mandatory parameter and call the action without setting it.

When debugging the ActionServiceImpl I could see the real exception was:

org.alfresco.service.cmr.rule.RuleServiceException: 01100058 Parameter 'namen' is mandatory, but no value was given.

but instead the logging said:

java.lang.ClassCastException: com.github.dynamicextensionsalfresco.actions.AnnotationBasedActionExecuter cannot be cast to org.alfresco.repo.action.executer.LoggingAwareExecuter

@kerkhofsd
Copy link
Contributor

Thanks for your PR, @tom-vandepoele !

Related issue: #278

The problem is that the LoggingAwareExecuter doesn't exist on Alfresco 5.0, which means this would break compatibility.

@tgeens
Copy link
Contributor

tgeens commented Feb 10, 2020

Can we polyfill that LoggingAwareExecuter on Alfresco 5.0 ?

@tom-vandepoele
Copy link
Contributor Author

If you were to include the interface source in the annotation runtime package, I think this resolves the problem. Alfresco 5 would not have any runtime problems as the interface exists and later versions would work too.

@kerkhofsd kerkhofsd force-pushed the AnnotationBasedActionExecuter-with-LoggingAwareExecuter branch from 3fc3bcb to 16519ec Compare February 28, 2020 09:57
@kerkhofsd
Copy link
Contributor

To make sure this doesn't get lost I rebased on the latest master.

@tom-vandepoele

If you were to include the interface source in the annotation runtime package, I think this resolves the problem. Alfresco 5 would not have any runtime problems as the interface exists and later versions would work too.

If we include the LoggingAwareExecuter in e.g. annotations-runtime, this will result in LinkageErrors for the Alfresco versions that already contain this interface...

I think we have two options:

  1. Drop 5.0 support, we could just include this fix AS-IS
  2. Setup a mechanisme / submodule with the 'LoggingAwareExecuter' interface that is only include in Alfresco 5.0.

tom-vandepoele and others added 2 commits March 12, 2020 09:31
… so exceptions in alfresco actions get handled the same as in ActionExecuterAbstractBase and not throw a java.lang.ClassCastException
@kerkhofsd kerkhofsd force-pushed the AnnotationBasedActionExecuter-with-LoggingAwareExecuter branch from 16519ec to df0696f Compare March 12, 2020 09:06
@kerkhofsd
Copy link
Contributor

Decision concerning this issue:

  • For DE 2.0, we introduce a LoggingAwareExecuter polyfill
  • For DE 2.1, we can drop Alfresco 5.0 support & hence also the polyfill.

I rebased the branch once again on master & include the polyfill for Alfresco 5.0

@kerkhofsd kerkhofsd requested a review from tgeens March 12, 2020 09:08
Copy link
Contributor

@tgeens tgeens left a comment

Choose a reason for hiding this comment

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

Looks good to me, but the sonar check fails ?

@kerkhofsd
Copy link
Contributor

Sonar fails because:
> You're not authorized to run analysis. Please contact the project administrator.

I suppose this is because it's build from the tom-vandepoele remote?
-> merging

@kerkhofsd kerkhofsd merged commit 3b04bc3 into xenit-eu:master Mar 12, 2020
@kerkhofsd
Copy link
Contributor

Thanks for the contribution @tom-vandepoele !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants