Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

JavaAPI/Scriptrunner - userAccessor takes too long, REST-Endpoint runs into time-out

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 22, 2024

Hi all,

I am running into performance issues within a confluence instance when fetching users data to build a custom endpoint.

Yes the number of users is quit high (2000 users) but I really wonder how the UI is managing when the JavaAPI is not capable.

So what I am trying to do:

  • get users from 3 different groups
  • fetching the user objects
  • building a JSON with several of it´s attributes

The logic works fine and for other groups (there are only a few hundred users) it works (even not really satisfying performance). As soon as fetching user objects kicks in it slows down.

When calling the script via endpoint I´m running into (kinda) timeout:

Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /rest/scriptrunner/latest/custom/<nameOfEndpoint>.

Reason: Error reading from remote server


I built the same functionality in Jira too and the UserUtil doesn´t have any problem with a higher amount of users.


See my code from confluence scriptrunner rest-endpoint:


    httpMethod: "GET"

) { MultivaluedMap queryParams, String body ->

    def maGroups = ["group_01", "group_02", "group_03"] as Collection<String>

    def billGroups = userAccessor.getGroupsAsList()?.findAll {'verrechnung-') && maGroups.contains( }



    def billUsers = [] as List<String>

    def users = []

    billGroups.each { group ->

        // def billUsers = [] as List<String>


        // log.warn("${}: ${billUsers}")

        log.warn("each: " +

        log.warn("billUsers: " + billUsers)

        log.warn("billUsers size: " + billUsers.size())



    billUsers.each { userName ->

        // def user = Users.getByName(userName)

        def user = userManager.getUser(userName)

        def billGroupsOfUser = userAccessor.getGroupNamesForUserName( { it.startsWith("verrechnung-") }

        def createdDate = crowdService.getUser('yyyy-MM-dd')

        def userSpaces = permissionFilter.getPermittedSpaceKeysForUser(user)



            billGroup: billGroupsOfUser.join(","),


            fullName: user.fullName,


            created: createdDate,

            spaces: userSpaces.join(", ")




    log.warn("users size(): " + users.size())

    def response = [users:users]

    log.warn("response: " + response)

    return Response.ok(new JsonBuilder(response).toString()).build()



Edit: more facts


users size(): 879



Elapsed: 34847 ms 

CPU time: 20819 ms



Any help appreciated.

Thanks in advance.



1 answer

0 votes
Andrii Maliuta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 1, 2024

Hello @Stefan Salzl ,

Did you check the internal implementation of the Java code - maybe you can compare the one in Jira and Confluence and see why it is so?

There are some other APIs that can be used for accessing user data - maybe they can be more effective if correctly combined :)


Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events