AEM 6.5 : Approach to avoid Cloud Manager AEM Rule for working listener implementation. | Community
Skip to main content
cquser1
Level 7
July 3, 2019

AEM 6.5 : Approach to avoid Cloud Manager AEM Rule for working listener implementation.

  • July 3, 2019
  • 2 replies
  • 9318 views

Hi All,

The error we are getting in CM is below

1] AEM-3[Non-thread safe object used as a field of Servlet/ Filter etc.]

Listener is working fine, but throwing above error for declaring session in our listener class which implements EventListener

private Session session ;

We are using this in activate() and deactivate() methods and looks like not possible to avoid the CM error.

2] Tried using Event Handler approach, wherein we want this to be invoked when page under certain path "/content/xxx" and few properties like "jcr:title"

are changed, the handler to be invoked for some custom processing.

Tried multiple things but no luck.

https://github.com/arunpatidar02/aem63app-repo/blob/master/java/TestEventHandler.java  didnt work either.

3] Via ResourceChangeListener approach, resourceChange.getAddedPropertyNames()/resourceChange.getChangedPropertyNames(); are deprecated.

4] Is it possible to solve this issue with the above approaches mentioned?

5] If no to #4, Creating launchers/workflows is the only alternative to get this to work?

Any thoughts/pointers on this will be really helpful.

Arun Patidar

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

cquser1
cquser1Author
Level 7
July 3, 2019

Just adding details : The listener implemented is on similar lines as done in Creating an Event Listener for Adobe Experience Manager 6.4.

To that implementation,  we are checking if eventIterator.nextEvent().getPath(); has the jcr:title and other properties and based on that we are adding our custom logic.

arunpatidar
Community Advisor
Community Advisor
July 4, 2019

Hi,

I tried same code from Creating an Event Listener for Adobe Experience Manager 6.4  in 6.5 and I am not getting any exception.

Arun Patidar
cquser1
cquser1Author
Level 7
July 4, 2019

Hi Arun,

I mean the code in Creating an Event Listener for Adobe Experience Manager 6.4  is working fine but cloud manager is throwing AEM-3[Non-thread safe object used as a field of Servlet/ Filter etc.] while deployment to our servers, which probably we will not be able to fix.

So, we were exploring other ways[mentioned above] of resolving this issue and if there is a way out.

joerghoh
Adobe Employee
Adobe Employee
July 5, 2019

This is an programming error indicated by the integrated sonar checks.

A filter is a singleton, which can be run concurrently. Thus it must not have any non-static final members, because these would be shared among the invocations, and invocation A could overwrite the value of invocation B. Thus avoid any global member inside a filter. (For servlets the same limitations exists.)

cquser1
cquser1Author
Level 7
July 8, 2019

Hi Joerg,

Thank you for the information provided.

However, we are not very sure as to how to modify the code to avoid this CM rule check.

Arun Patidar​ Adding a finally block didn't help much. Any pointers/ thoughts on how this can be done will be helpful.

arunpatidar
Community Advisor
Community Advisor
July 8, 2019

Hi,

According to adobe

The quality scanning process is not perfect and will sometimes incorrectly identify issues which are not actually problematic. This is referred to as a "false positive".

In these cases, the source code can be annotated with the standard Java @SuppressWarnings annotation specifying the rule ID as the annotation attribute.

Example

@SuppressWarnings("AEM Rules:AEM-3")

private Session adminSession;

Arun Patidar