[MGNLHOOK-267] NullPointerException when empty events Created: 28/Oct/22  Updated: 23/Oct/23

Status: Backlog
Project: Magnolia Webhooks
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Phong Le Quoc Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
relation
is related to MGNLHOOK-210 NPE when processing info.magnolia.typ... Closed
Team: DeveloperX
Date of First Response:
Epic Link: Webhooks Maintenance (Phase 2)
Story Points: 1

 Description   

When creating a webhook definition with empty events, there will be a NullPointerException. There is also NullPointerException when changing other content types.

Ex:

name: webhook1
url: https://httpdump.io/ne_sz
method: get
enabled: true

events: 

Note: there is no exception if we don't define "events"

2022-10-28 14:14:00,498 INFO  onfiguration.RestClientRegistryConfigurationSource: Registered Rest Client definition from Webhook definition [webhook-mgnlhook-201:webhookConfig_1]: [restClient] definition [webhook-mgnlhook-201:webhookConfig_1] with reference id: [webhook-mgnlhook-201:webhookConfig_1] from module [webhooks-core] at [webhook-mgnlhook-201:webhookConfig_1]
2022-10-28 14:14:00,504 ERROR info.magnolia.event.SimpleEventBus                : Exception caught when dispatching info.magnolia.webhooks.core.WebhookDefinitionChangedEvent with info.magnolia.webhooks.registry.WebhookDefinitionEventHandler eventHandler.
java.lang.NullPointerException: null
    at info.magnolia.webhooks.registry.WebhookDefinitionEventHandler.onChange(WebhookDefinitionEventHandler.java:68) ~[magnolia-webhooks-core-1.0.1-SNAPSHOT.jar:?]
    at info.magnolia.webhooks.core.WebhookDefinitionChangedEvent.dispatch(WebhookDefinitionChangedEvent.java:57) ~[magnolia-webhooks-core-1.0.1-SNAPSHOT.jar:?]
    at info.magnolia.webhooks.core.WebhookDefinitionChangedEvent.dispatch(WebhookDefinitionChangedEvent.java:28) ~[magnolia-webhooks-core-1.0.1-SNAPSHOT.jar:?]
    at info.magnolia.event.SimpleEventBus.fireEvent(SimpleEventBus.java:75) ~[magnolia-core-6.2-SNAPSHOT.jar:?]
    at info.magnolia.webhooks.registry.WebhookDefinitionRegistry.register(WebhookDefinitionRegistry.java:92) ~[magnolia-webhooks-core-1.0.1-SNAPSHOT.jar:?]
    at info.magnolia.config.source.yaml.YamlConfigurationSource.loadAndRegister(YamlConfigurationSource.java:143) ~[magnolia-configuration-6.2-SNAPSHOT.jar:?]
    at info.magnolia.config.source.yaml.AbstractFileResourceConfigurationSource.lambda$start$2(AbstractFileResourceConfigurationSource.java:162) ~[magnolia-configuration-6.2-SNAPSHOT.jar:?]
    at info.magnolia.resourceloader.layered.LayeredResourceOrigin$RelayingChangeHandler.onResourceChanged(LayeredResourceOrigin.java:284) ~[magnolia-resource-loader-6.2-SNAPSHOT.jar:?]
    at info.magnolia.resourceloader.AbstractResourceOrigin.dispatchResourceChange(AbstractResourceOrigin.java:132) ~[magnolia-resource-loader-6.2-SNAPSHOT.jar:?]
    at info.magnolia.resourceloader.file.FileWatcherCallback.dispatchResourceChange(FileWatcherCallback.java:118) ~[magnolia-resource-loader-6.2-SNAPSHOT.jar:?]
    at info.magnolia.resourceloader.file.FileWatcherCallback.modified(FileWatcherCallback.java:89) ~[magnolia-resource-loader-6.2-SNAPSHOT.jar:?]
    at info.magnolia.dirwatch.DirectoryWatcher.processEvent(DirectoryWatcher.java:303) ~[magnolia-resource-loader-6.2-SNAPSHOT.jar:?]
    at info.magnolia.dirwatch.DirectoryWatcher.run(DirectoryWatcher.java:247) ~[magnolia-resource-loader-6.2-SNAPSHOT.jar:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[?:?]
    at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
    at java.lang.Thread.run(Thread.java:829) ~[?:?]
2022-10-28 14:14:00,537 INFO  agnolia.config.source.yaml.YamlConfigurationSource: Registered definition from YAML file [/mgnlhook-201/webhooks/webhookConfig_1.yaml]: [webhook] definition [webhook1] with reference id: [mgnlhook-201:webhookConfig_1] from module [mgnlhook-201] at [webhookConfig_1]
2022-10-28 14:14:00,537 WARN  agnolia.config.source.yaml.YamlConfigurationSource: 0 major and 1 minor problems have been encountered
 


 Comments   
Comment by Phong Le Quoc [ 28/Oct/22 ]

Although our document does not accept an empty event list. However, our customers could do it easily(intend or not). In addition, we should not let our code throws NullPointerException in any cases.

Generated at Mon Feb 12 10:02:37 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.