Summary
Sharing a page to an email address results in SQL syntax error exception
Environment
- Postgres 9.5
- SMTP configured
- No Mobile App subscriptions
Steps to Reproduce
- Go to a Confluence page
- Click on Share button (need to have SMTP configured)
- Type in an email address into Add people list
- Click Share

Expected Results
- Email is sent to the user with link and information on the page
Actual Results
Email is received as expected, but below exception is thrown in the atlassian.confluence.log file:
2018-11-14 16:39:50,867 ERROR [AtlassianEvent::CustomizableThreadFactory-1] [atlassian.confluence.event.ConfluenceEventDispatcher] run There was an exception thrown trying to dispatch event [com.atlassian.mywork.event.notification.PushNotificationEvent@7ee35055] from the invoker [com.atlassian.confluence.event.ConfluenceListenerHandlersConfiguration$TimingListenerHandler$1$1@279aaf3e] -- url: /c6111/rest/share-page/latest/share | traceId: 999a5bb25e4f54d6 | userName: admin | referer: http://localhost:26111/c6111/display/678/test java.lang.RuntimeException: There was a SQL exception thrown by the Active Objects library: Database: - name:PostgreSQL - version:9.5.12 - minor version:5 - major version:9 Driver: - name:PostgreSQL JDBC Driver - version:42.1.1 org.postgresql.util.PSQLException: ERROR: syntax error at or near ")" Position: 169. Listener: com.atlassian.confluence.plugins.mobile.listener.PushNotificationEventListener event: com.atlassian.mywork.event.notification.PushNotificationEvent at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:55) at com.atlassian.confluence.event.ConfluenceListenerHandlersConfiguration$TimingListenerHandler$1$1.invoke(ConfluenceListenerHandlersConfiguration.java:69) at com.atlassian.confluence.event.ConfluenceEventDispatcher$VCacheRequestContextRunnableFactory$1.lambda$run$0(ConfluenceEventDispatcher.java:93) at com.atlassian.confluence.vcache.VCacheRequestContextOperations.lambda$doInRequestContext$0(VCacheRequestContextOperations.java:50) at com.atlassian.confluence.impl.vcache.VCacheRequestContextManager.doInRequestContextInternal(VCacheRequestContextManager.java:87) at com.atlassian.confluence.impl.vcache.VCacheRequestContextManager.doInRequestContext(VCacheRequestContextManager.java:71) at com.atlassian.confluence.vcache.VCacheRequestContextOperations.doInRequestContext(VCacheRequestContextOperations.java:49) at com.atlassian.confluence.event.ConfluenceEventDispatcher$VCacheRequestContextRunnableFactory$1.run(ConfluenceEventDispatcher.java:93) at com.atlassian.confluence.event.ConfluenceEventDispatcher$1.run(ConfluenceEventDispatcher.java:61) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: com.atlassian.activeobjects.internal.ActiveObjectsSqlException: There was a SQL exception thrown by the Active Objects library: Database: - name:PostgreSQL - version:9.5.12 - minor version:5 - major version:9 Driver: - name:PostgreSQL JDBC Driver - version:42.1.1 org.postgresql.util.PSQLException: ERROR: syntax error at or near ")" Position: 169 at com.atlassian.activeobjects.internal.EntityManagedActiveObjects.find(EntityManagedActiveObjects.java:142) at com.atlassian.activeobjects.osgi.TenantAwareActiveObjects.find(TenantAwareActiveObjects.java:296) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56) at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
It appears that Mobile App Plug-in push module is invoked whenever a page is shared to an email address, so the following function is called
PushNotificationDaoImpl.java
public List<PushNotificationAO> findByUserNames(@Nonnull Set<String> userNames, boolean isActive) {
String whereClause = "USER_NAME IN (" + buildQuestionPlaceholder(userNames) + ") AND ACTIVE = ?" ;
List<Object> params = new ArrayList<>(userNames);
params.add(isActive);
return ao.executeInTransaction(
() -> Arrays.asList(ao.find(PushNotificationAO.class, select()
.where(whereClause, params.toArray())))
);
}
However, if there are no mobile app subscribers, table AO_954A21_PUSH_NOTIFICATION_AO is empty, so this function fails to populate data in (" + buildQuestionPlaceholder(userNames) brackets, resulting in syntax ERROR.
Workaround
Disabling Mobile Push Notification from
> General Configuration > Mobile apps prevents the error from getting logged.
The issue is not logged if the page is shared with a user or a group