Cannot use ContentService.find().withSpace() and ContentType.ATTACHMENT

It seems that the withSpace method of AbstractContentFinder does not set the contentContainerId. This results in a null value being passed to the AttachmentContentTypeApiSupport.getAttachments method which results in a NullPointerException when it tries to call the asLong() method on the null value.

I am using Confluence 7.0.1 so perhaps this has already been fixed?

[relevant stacktrace]

Cause
java.lang.NullPointerException
at com.atlassian.confluence.api.impl.service.content.typebinding.AttachmentContentTypeApiSupport.getAttachments(AttachmentContentTypeApiSupport.java:98)

java.lang.NullPointerException
at com.atlassian.confluence.api.impl.service.content.typebinding.AttachmentContentTypeApiSupport.getAttachments(AttachmentContentTypeApiSupport.java:98)
at com.atlassian.confluence.api.impl.service.content.finder.ContentFinderFactory$ContentFinderImpl.internalFetchAttachments(ContentFinderFactory.java:149)
at com.atlassian.confluence.api.impl.service.content.finder.ContentFinderFactory$ContentFinderImpl.fetchMany(ContentFinderFactory.java:134)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

I also have this exact problem on 7.11.0. Did you ever find a solution @robertegan305?

I cannot use the ContentService to find attachments using a simple query like this:

contentService.find(Expansions.of(CONTAINER).toArray()).withStatus(ContentStatus.CURRENT).fetchMany(ATTACHMENT, new SimplePageRequest(0, 200))

It always errors out with:

java.lang.NullPointerException
	at com.atlassian.confluence.api.impl.service.content.typebinding.AttachmentContentTypeApiSupport.getAttachments(AttachmentContentTypeApiSupport.java:98)
	at com.atlassian.confluence.api.impl.service.content.finder.ContentFinderFactory$ContentFinderImpl.internalFetchAttachments(ContentFinderFactory.java:148)
	at com.atlassian.confluence.api.impl.service.content.finder.ContentFinderFactory$ContentFinderImpl.fetchMany(ContentFinderFactory.java:133)
	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:344)

@jponting you wrote a post on how to use the ContentService, could you check whether this is a bug or not?