java.util.NoSuchElementException: null

Atlassian JIRA | Pierre-Etienne Poirot [Atlassian] | 2 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    Since 3.2, Stash by default delays the deletion of any user by a week to be resilient to transient deletions (see STASH-4631 for more details). This is internally performed by a background job, {{UserCleanupJob}}, that executes (again by default) every 6 hours. As part of this job, Stash fetches the users that were deleted in a [User Directory|https://confluence.atlassian.com/display/STASH032/External+user+directories] a week or more ago. Then for each user, it marks them as deleted. (Stash cannot fully delete an user in the database because it needs to preserve the user's pull requests, comments, etc. However the user will no longer have access to Stash). The problem with the current implementation of {{UserCleanupJob}} is that it currently fetches the users (by batch of 100) and update them within the same transaction. As a result, if there is more 100 users, an error is thrown and as a result the transaction is rollback: {noformat} 2014-11-28 09:39:33,051 ERROR [clusterScheduler_Worker-1] c.a.scheduler.core.JobLauncher Scheduled job with ID 'UserCleanupJob' failed java.util.NoSuchElementException: null at com.google.common.collect.Iterators$9.next(Iterators.java:966) ~[guava-11.0.2-atlassian-01.jar:na] at com.atlassian.stash.util.PagedIterable$PagedIterator.next(PagedIterable.java:48) ~[stash-util-3.2.7.jar:na] at com.atlassian.stash.internal.user.DefaultUserAdminService$3.doInTransactionWithoutResult(DefaultUserAdminService.java:620) ~[stash-service-impl-3.2.7.jar:na] at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:34) ~[spring-tx-4.0.5.RELEASE.jar:4.0.5.RELEASE] at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133) ~[spring-tx-4.0.5.RELEASE.jar:4.0.5.RELEASE] at com.atlassian.stash.internal.user.DefaultUserAdminService.cleanupDeletedUsers(DefaultUserAdminService.java:608) ~[stash-service-impl-3.2.7.jar:na] at com.atlassian.stash.internal.user.DefaultUserAdminService$UserCleanupJob.runJob(DefaultUserAdminService.java:648) ~[stash-service-impl-3.2.7.jar:na] at com.atlassian.scheduler.core.JobLauncher.runJob(JobLauncher.java:127) [atlassian-scheduler-core-1.2.2.jar:na] at com.atlassian.scheduler.core.JobLauncher.launchAndBuildResponse(JobLauncher.java:101) [atlassian-scheduler-core-1.2.2.jar:na] at com.atlassian.scheduler.core.JobLauncher.launch(JobLauncher.java:80) [atlassian-scheduler-core-1.2.2.jar:na] at com.atlassian.scheduler.quartz1.Quartz1Job.execute(Quartz1Job.java:32) [atlassian-scheduler-quartz1-1.2.2.jar:na] at org.quartz.core.JobRunShell.run(JobRunShell.java:223) [quartz-1.8.6.jar:na] at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549) [quartz-1.8.6.jar:na] {noformat}

    Atlassian JIRA | 2 years ago | Pierre-Etienne Poirot [Atlassian]
    java.util.NoSuchElementException: null
  2. 0

    Since 3.2, Stash by default delays the deletion of any user by a week to be resilient to transient deletions (see STASH-4631 for more details). This is internally performed by a background job, {{UserCleanupJob}}, that executes (again by default) every 6 hours. As part of this job, Stash fetches the users that were deleted in a [User Directory|https://confluence.atlassian.com/display/STASH032/External+user+directories] a week or more ago. Then for each user, it marks them as deleted. (Stash cannot fully delete an user in the database because it needs to preserve the user's pull requests, comments, etc. However the user will no longer have access to Stash). The problem with the current implementation of {{UserCleanupJob}} is that it currently fetches the users (by batch of 100) and update them within the same transaction. As a result, if there is more 100 users, an error is thrown and as a result the transaction is rollback: {noformat} 2014-11-28 09:39:33,051 ERROR [clusterScheduler_Worker-1] c.a.scheduler.core.JobLauncher Scheduled job with ID 'UserCleanupJob' failed java.util.NoSuchElementException: null at com.google.common.collect.Iterators$9.next(Iterators.java:966) ~[guava-11.0.2-atlassian-01.jar:na] at com.atlassian.stash.util.PagedIterable$PagedIterator.next(PagedIterable.java:48) ~[stash-util-3.2.7.jar:na] at com.atlassian.stash.internal.user.DefaultUserAdminService$3.doInTransactionWithoutResult(DefaultUserAdminService.java:620) ~[stash-service-impl-3.2.7.jar:na] at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:34) ~[spring-tx-4.0.5.RELEASE.jar:4.0.5.RELEASE] at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133) ~[spring-tx-4.0.5.RELEASE.jar:4.0.5.RELEASE] at com.atlassian.stash.internal.user.DefaultUserAdminService.cleanupDeletedUsers(DefaultUserAdminService.java:608) ~[stash-service-impl-3.2.7.jar:na] at com.atlassian.stash.internal.user.DefaultUserAdminService$UserCleanupJob.runJob(DefaultUserAdminService.java:648) ~[stash-service-impl-3.2.7.jar:na] at com.atlassian.scheduler.core.JobLauncher.runJob(JobLauncher.java:127) [atlassian-scheduler-core-1.2.2.jar:na] at com.atlassian.scheduler.core.JobLauncher.launchAndBuildResponse(JobLauncher.java:101) [atlassian-scheduler-core-1.2.2.jar:na] at com.atlassian.scheduler.core.JobLauncher.launch(JobLauncher.java:80) [atlassian-scheduler-core-1.2.2.jar:na] at com.atlassian.scheduler.quartz1.Quartz1Job.execute(Quartz1Job.java:32) [atlassian-scheduler-quartz1-1.2.2.jar:na] at org.quartz.core.JobRunShell.run(JobRunShell.java:223) [quartz-1.8.6.jar:na] at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549) [quartz-1.8.6.jar:na] {noformat}

    Atlassian JIRA | 2 years ago | Pierre-Etienne Poirot [Atlassian]
    java.util.NoSuchElementException: null

    Root Cause Analysis

    1. java.util.NoSuchElementException

      null

      at com.google.common.collect.Iterators$9.next()
    2. Guava
      Iterators$9.next
      1. com.google.common.collect.Iterators$9.next(Iterators.java:966)[guava-11.0.2-atlassian-01.jar:na]
      1 frame
    3. com.atlassian.stash
      DefaultUserAdminService$3.doInTransactionWithoutResult
      1. com.atlassian.stash.util.PagedIterable$PagedIterator.next(PagedIterable.java:48)[stash-util-3.2.7.jar:na]
      2. com.atlassian.stash.internal.user.DefaultUserAdminService$3.doInTransactionWithoutResult(DefaultUserAdminService.java:620)[stash-service-impl-3.2.7.jar:na]
      2 frames
    4. Spring Tx
      TransactionTemplate.execute
      1. org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:34)[spring-tx-4.0.5.RELEASE.jar:4.0.5.RELEASE]
      2. org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)[spring-tx-4.0.5.RELEASE.jar:4.0.5.RELEASE]
      2 frames
    5. com.atlassian.stash
      DefaultUserAdminService$UserCleanupJob.runJob
      1. com.atlassian.stash.internal.user.DefaultUserAdminService.cleanupDeletedUsers(DefaultUserAdminService.java:608)[stash-service-impl-3.2.7.jar:na]
      2. com.atlassian.stash.internal.user.DefaultUserAdminService$UserCleanupJob.runJob(DefaultUserAdminService.java:648)[stash-service-impl-3.2.7.jar:na]
      2 frames
    6. com.atlassian.scheduler
      Quartz1Job.execute
      1. com.atlassian.scheduler.core.JobLauncher.runJob(JobLauncher.java:127)[atlassian-scheduler-core-1.2.2.jar:na]
      2. com.atlassian.scheduler.core.JobLauncher.launchAndBuildResponse(JobLauncher.java:101)[atlassian-scheduler-core-1.2.2.jar:na]
      3. com.atlassian.scheduler.core.JobLauncher.launch(JobLauncher.java:80)[atlassian-scheduler-core-1.2.2.jar:na]
      4. com.atlassian.scheduler.quartz1.Quartz1Job.execute(Quartz1Job.java:32)[atlassian-scheduler-quartz1-1.2.2.jar:na]
      4 frames
    7. quartz
      SimpleThreadPool$WorkerThread.run
      1. org.quartz.core.JobRunShell.run(JobRunShell.java:223)[quartz-1.8.6.jar:na]
      2. org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)[quartz-1.8.6.jar:na]
      2 frames