Details
-
Bug
-
Resolution: Fixed
-
Low
-
6.4
-
6.04
-
Description
A NullPointerException occurs when running tasks on non-HTTP-executor-threads (ie. Quartz jobs or background tasks) that make calls to JiraWebResourceIntegrartion#getBaseUrl where urlMode = UrlMode.RELATIVE. This execution path worked fine in 6.3, so this is a regression in 6.4:
java.lang.NullPointerException at com.atlassian.jira.plugin.webresource.JiraWebResourceIntegration.getBaseUrl(JiraWebResourceIntegration.java:127) at com.atlassian.plugin.webresource.WebResourceUrlProviderImpl.getStaticResourcePrefix(WebResourceUrlProviderImpl.java:47) at com.atlassian.jira.plugin.webresource.JiraWebResourceUrlProvider.getStaticResourcePrefix(JiraWebResourceUrlProvider.java:44)
This bug hit one of our plugins because we were calling JiraWebResourceUrlProvider#getStaticResourcePrefix, but we were able to work around that specific instance by using UrlMode.AUTO instead.
However, this bug causes another problem with no easy workaround. If a task also needs to grab a DownloadableResource from a non-HTTP-executor thread, the following exception occurs because JIRA's RelativeUrlTransformerFactory#createUrlPrefixRef method uses a hardcoded "UrlMode.RELATIVE" and there is no option to override it:
Caused by: java.lang.NullPointerException at com.atlassian.jira.plugin.webresource.JiraWebResourceIntegration.getBaseUrl(JiraWebResourceIntegration.java:127) at com.atlassian.plugin.webresource.WebResourceUrlProviderImpl.getStaticResourcePrefix(WebResourceUrlProviderImpl.java:47) at com.atlassian.jira.plugin.webresource.JiraWebResourceUrlProvider.getStaticResourcePrefix(JiraWebResourceUrlProvider.java:44) at com.atlassian.plugin.webresource.transformer.instance.RelativeUrlTransformerFactory$RelativeUrlTransformer$2.create(RelativeUrlTransformerFactory.java:119) at com.atlassian.plugin.webresource.transformer.instance.RelativeUrlTransformerFactory$RelativeUrlTransformer$2.create(RelativeUrlTransformerFactory.java:110) at com.atlassian.util.concurrent.LazyReference$Sync.run(LazyReference.java:325) at com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:143) ... 36 more
The regression stems from this specific code in JiraWebResourceIntegration#getBaseUrl:
public String getBaseUrl(final UrlMode urlMode) { switch (urlMode) { case RELATIVE: return ExecutingHttpRequest.get().getContextPath(); case AUTO: // This may return a canonical URL, depending on the type of request being handled. return requestContextFactory.getJiraVelocityRequestContext().getBaseUrl(); case ABSOLUTE: return requestContextFactory.getJiraVelocityRequestContext().getCanonicalBaseUrl(); default: throw new AssertionError("Unsupported URLMode: " + urlMode); } }
urlMode is relative, so "ExecutingHttpRequest.get()" presumably returns null when not run on an HTTP-executor thread.
In 6.3, this code instead looked like this and it worked properly:
99 public String getBaseUrl(final UrlMode urlMode) 100 { 101 switch (urlMode) 102 { 103 case RELATIVE: 104 case AUTO: 105 return requestContextFactory.getJiraVelocityRequestContext().getBaseUrl(); 106 case ABSOLUTE: 107 return requestContextFactory.getJiraVelocityRequestContext().getCanonicalBaseUrl(); 108 default: 109 throw new AssertionError("Unsupported URLMode: " + urlMode); 110 } 111 }
Attachments
Issue Links
- is related to
-
JSDSERVER-2238 NullPointerException when ServiceDesk sends Notification Email
- Closed
-
JRASERVER-43418 DefaultGadgetSpecFactory performs anonymous requests
- Gathering Impact
- was cloned as
-
APDEX-198 Loading...