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

Fix NPE when API has not yet been defined. #112

Merged
merged 2 commits into from
May 26, 2023

Conversation

karelmaxa
Copy link
Member

I have fixed the NullPointerException in SmsRequestHandler when the api is not defined yet. Related stacktrace:

ERROR: SMSNotificationManager.objectChanged Exception for class: org.forgerock.openam.core.rest.sms.SmsRequestHandler
java.lang.NullPointerException: Cannot invoke "org.forgerock.api.models.ApiDescription.equals(Object)" because "oldApi" is null
	at org.forgerock.openam.core.rest.sms.SmsRequestHandler.notifyDescriptorChange(SmsRequestHandler.java:832)
	at org.forgerock.openam.core.rest.sms.SmsRequestHandler.refreshServiceRoute(SmsRequestHandler.java:355)
	at org.forgerock.openam.core.rest.sms.SmsRequestHandler.objectChanged(SmsRequestHandler.java:324)
	at com.sun.identity.sm.SMSNotificationManager.sendNotifications(SMSNotificationManager.java:294)
	at com.sun.identity.sm.SMSNotificationManager$LocalChangeNotifcationTask.run(SMSNotificationManager.java:370)
	at org.forgerock.openam.audit.context.AuditRequestContextPropagatingRunnable.run(AuditRequestContextPropagatingRunnable.java:42)
	at com.iplanet.am.util.ThreadPool$WorkerThread.run(ThreadPool.java:314)

@karelmaxa karelmaxa requested a review from pavelhoral May 26, 2023 07:37
pavelhoral
pavelhoral previously approved these changes May 26, 2023
Copy link
Member

@pavelhoral pavelhoral left a comment

Choose a reason for hiding this comment

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

LGTM

@pavelhoral
Copy link
Member

pavelhoral commented May 26, 2023

On a second look there are few suspicious things in that class:

There are locks being used when accessing route routeTree property and there are no locks when working with apiListeners. There is even apparent inconsistency between #removeDescriptionListener and synchronized #notifyDescriptionChange. Seems to be ConcurrentModificationException hiding in there.

@karelmaxa can you please confirm that there is no synchronization issue here?

Copy link
Member

@pavelhoral pavelhoral left a comment

Choose a reason for hiding this comment

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

Ty for the changes.

@pavelhoral pavelhoral merged commit 706bc5c into WrenSecurity:main May 26, 2023
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.

2 participants