Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

How to use #onChange in ResourceChangeListener


Level 5


I would like to know if and why do I need the NotNull Constraint when implementing onChange in ResourceChangeListener. Here is the code:


public class ComponentCampaignCleanupListener implements ResourceChangeListener {

private static final Logger logger = LoggerFactory.getLogger(ComponentCampaignCleanupListener.class);

private ResourceResolverService resourceResolverService;

public void onChange(List<ResourceChange> list) {...} //**Do I need here @NotNull for the list parameter and why?
3 Replies


Level 6

I dont think it is mandatory to define notnull here. Refer below 


The @notnull Annotation is, actually, an explicit contract declaring the following:

  1. A method should not return null.
  2. A variable (like fields, local variables, and parameters) cannot should not hold null value.

Additionally, @notnull is often checked by ConstraintValidators (eg. in spring and hibernate).

The @notnull annotation doesn't do any validation on its own because the annotation definition does not provide any ConstraintValidator type reference.


Level 5

Thanks @tusharbias 

In my specific case the list variable could be null. I am listening to /content ADDED changes. In fact, if I add the @NotNull constraint AEM I cannot render any Page and get a compilation error.

The reason why I posted the question is that I thought according to the interface, this method should have a @NotNull annotation.


Here is the interface:

public interface ResourceChangeListener {
String PATHS = "resource.paths";
String CHANGES = "resource.change.types";

void onChange(@NotNull List<ResourceChange> var1);


Community Advisor

Hi @anasustic ,

If you want to use Javax validation constraints to ensure that the List<ResourceChange> list

 being passed in is not null then @NotNull annotation is being used.

Fore more details please visit:

Hope that helps!



The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now