java.util.NoSuchElementException: Iterator depleted

Sonatype JIRA | Benjamin Bentmann | 3 months ago
tip
Do you find the tips below useful? Click on the to mark them and say thanks to rafafviola and rp . Or join the community to write better ones.
  1. 0

    https://github.com/sonatype/nexus-internal/blob/c341bcc9311c122cc17d51df0abb30920b2fe33f/components/nexus-repository/src/main/java/org/sonatype/nexus/repository/storage/OrientAsyncHelper.java#L184 The {{queue.poll()}} invocation there yields no exception but {{null}} when the timeout elapses. This causes the following issues: # {{hasNext()}} returning {{true}} when in reality no element is available # {{next()}} returning a non-deterministic number of {{null}} elements tripping up processing of the query results, e.g. {noformat} 2017-01-10 15:09:20,084+0100 ERROR [qtp172586730-295] admin org.sonatype.nexus.extdirect.internal.ExtDirectServlet - Failed to invoke action method: coreui_Component.read, java-method: org.sonatype.nexus.coreui.ComponentComponent.read java.lang.IllegalArgumentException: expected one element but was: <null, null, null, null, null, ...> at com.google.common.collect.Iterators.getOnlyElement(Iterators.java:322) [com.google.guava:20.0.0] at com.google.common.collect.Iterables.getOnlyElement(Iterables.java:294) [com.google.guava:20.0.0] at org.sonatype.nexus.repository.browse.internal.BrowseServiceImpl.getCount(BrowseServiceImpl.java:192) [na:na] at org.sonatype.nexus.repository.browse.internal.BrowseServiceImpl.browseComponents(BrowseServiceImpl.java:95) [na:na] at org.sonatype.nexus.repository.browse.BrowseService$browseComponents.call(Unknown Source) [na:na] at org.sonatype.nexus.coreui.ComponentComponent.read(ComponentComponent.groovy:126) [na:na] {noformat} # {{next()}} failing with {{NoSuchElementException}} although the caller previously checked {{hasNext() == true}} ({{next()}} calls {{hasNext()}} again and can observe a different value than the caller, like the end-of-query sentinel), e.g. {noformat} Suppressed: java.util.NoSuchElementException: Iterator depleted at org.sonatype.nexus.repository.storage.OrientAsyncHelper$QueueConsumingIterable.next(OrientAsyncHelper.java:202) [na:na] at org.sonatype.nexus.repository.storage.OrientAsyncHelper$QueueConsumingIterable.next(OrientAsyncHelper.java:1) [na:na] at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:47) [com.google.guava:20.0.0] at org.sonatype.nexus.repository.maven.internal.PurgeUnusedSnapshotsFacetImpl.deleteUnusedSnapshotComponents(PurgeUnusedSnapshotsFacetImpl.java:165) [na:na] {noformat}

    Sonatype JIRA | 3 months ago | Benjamin Bentmann
    java.util.NoSuchElementException: Iterator depleted
  2. 0
    samebug tip
    Try looking for variables that have been declared but not created as an object on the functions described in the stack trace.
  3. 0
    samebug tip
    Upgrade your old nexus to 2.14.1-01
    via Sonatype JIRA by Marc Lévi
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    The Maven facet attempts to fill in information about a pom using the {{MavenModels.readModel}} function. If the supplied input stream is empty, this throws an exception and causes issues upstream when we (for example) attempt to migrate a zero-length pom or deploy one to a hosted repository (see stack trace of resulting HTTP 500 error below). The javadoc for the method in question says that it should "return \{@code null\} if input not parsable". It seems more consistent to return null when the input stream is empty instead of throwing an EOFException, but what would that cause unintended side-effects? For reference, NX2 does not reject deployments of empty POMs. {noformat} 2017-02-08 19:25:17,516+0100 WARN [qtp571182704-310] admin org.sonatype.nexus.repository.httpbridge.internal.ViewServlet - Service failure java.io.EOFException: input contained no data at org.codehaus.plexus.util.xml.pull.MXParser.fillBuf(MXParser.java:3037) [na:na] at org.codehaus.plexus.util.xml.pull.MXParser.more(MXParser.java:3080) [na:na] at org.codehaus.plexus.util.xml.pull.MXParser.parseProlog(MXParser.java:1451) [na:na] at org.codehaus.plexus.util.xml.pull.MXParser.nextImpl(MXParser.java:1436) [na:na] at org.codehaus.plexus.util.xml.pull.MXParser.next(MXParser.java:1131) [na:na] at org.apache.maven.model.io.xpp3.MavenXpp3Reader.read(MavenXpp3Reader.java:3811) [na:na] at org.apache.maven.model.io.xpp3.MavenXpp3Reader.read(MavenXpp3Reader.java:557) [na:na] at org.apache.maven.model.io.xpp3.MavenXpp3Reader.read(MavenXpp3Reader.java:586) [na:na] at org.sonatype.nexus.repository.maven.internal.MavenModels.readModel(MavenModels.java:132) [na:na] at org.sonatype.nexus.repository.maven.internal.MavenFacetImpl.fillInFromModel(MavenFacetImpl.java:367) [na:na] at org.sonatype.nexus.repository.maven.internal.MavenFacetImpl.putArtifact(MavenFacetImpl.java:325) [na:na] at org.sonatype.nexus.repository.maven.internal.MavenFacetImpl.doPutAssetBlob(MavenFacetImpl.java:295) [na:na] at org.sonatype.nexus.repository.maven.internal.MavenFacetImpl.doPut(MavenFacetImpl.java:248) [na:na] at org.sonatype.nexus.transaction.TransactionalWrapper.proceedWithTransaction(TransactionalWrapper.java:56) [na:na] at org.sonatype.nexus.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:54) [na:na] at org.sonatype.nexus.repository.maven.internal.MavenFacetImpl.put(MavenFacetImpl.java:200) [na:na] at org.sonatype.nexus.repository.maven.internal.hosted.HostedHandler.doPut(HostedHandler.java:87) [na:na] at org.sonatype.nexus.repository.maven.internal.hosted.HostedHandler.handle(HostedHandler.java:61) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at org.sonatype.nexus.repository.storage.UnitOfWorkHandler.handle(UnitOfWorkHandler.java:39) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at org.sonatype.nexus.repository.view.handlers.ContentHeadersHandler.handle(ContentHeadersHandler.java:44) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at org.sonatype.nexus.repository.maven.internal.VersionPolicyHandler.handle(VersionPolicyHandler.java:60) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at org.sonatype.nexus.repository.http.PartialFetchHandler.handle(PartialFetchHandler.java:55) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at org.sonatype.nexus.repository.view.handlers.ConditionalRequestHandler.handle(ConditionalRequestHandler.java:72) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at com.sonatype.nexus.clm.internal.QuarantineContributedHandler.handle(QuarantineContributedHandler.java:62) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at org.sonatype.nexus.repository.view.handlers.HandlerContributor.handle(HandlerContributor.java:67) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at org.sonatype.nexus.repository.view.handlers.ExceptionHandler.handle(ExceptionHandler.java:43) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at org.sonatype.nexus.repository.security.SecurityHandler.handle(SecurityHandler.java:52) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at org.sonatype.nexus.repository.view.handlers.TimingHandler.handle(TimingHandler.java:46) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at org.sonatype.nexus.repository.view.Context.start(Context.java:114) [na:na] at org.sonatype.nexus.repository.view.Router.dispatch(Router.java:63) [na:na] at org.sonatype.nexus.repository.view.ConfigurableViewFacet.dispatch(ConfigurableViewFacet.java:52) [na:na] at org.sonatype.nexus.repository.view.ConfigurableViewFacet.dispatch(ConfigurableViewFacet.java:43) [na:na] at org.sonatype.nexus.repository.httpbridge.internal.ViewServlet.dispatchAndSend(ViewServlet.java:197) [na:na] at org.sonatype.nexus.repository.httpbridge.internal.ViewServlet.doService(ViewServlet.java:159) [na:na] at org.sonatype.nexus.repository.httpbridge.internal.ViewServlet.service(ViewServlet.java:116) [na:na] {noformat}

    Sonatype JIRA | 2 months ago | Eric Cobb
    java.io.EOFException: input contained no data
  6. 0

    If a user has read privileges to a npm group, but not the underlying npm proxy, then the "npm install <package>" will get a 500 response for any package that is not locally cached in the npm proxy. Steps to reproduce: 1) Setup a npm group _npm-all_ that has npm proxy _npmjs_ as a member 2) Setup a user that has access to group repo _npm-all_ (privilege nx-repository-view-npm-npm-all). 3) Try to install a npm package that is not locally cached in proxy _npmjs_ The npm install command will fail with something like the following: {noformat} npm http fetch GET http://localhost:8081/repository/npm-all/glob/-/glob-7.1.1.tgz npm http fetch 500 http://localhost:8081/repository/npm-all/glob/-/glob-7.1.1.tgz npm info retry will retry, error on last attempt: Error: server error 500 {noformat} Nexus logs will show the following: {noformat} 2016-12-21 11:21:38,899+0000 WARN [qtp1898010376-415] test org.sonatype.nexus.repository.httpbridge.internal.ViewServlet - Service failure java.lang.RuntimeException: java.io.IOException: org.apache.shiro.authz.AuthorizationException at com.google.common.base.Throwables.propagate(Throwables.java:160) [na:na] at com.sonatype.nexus.repository.npm.internal.NpmProxyFacetImpl.getUrl(NpmProxyFacetImpl.java:142) [na:na] at org.sonatype.nexus.repository.proxy.ProxyFacetSupport.fetch(ProxyFacetSupport.java:210) [na:na] at com.sonatype.nexus.repository.npm.internal.NpmProxyFacetImpl.fetch(NpmProxyFacetImpl.java:62) [na:na] at org.sonatype.nexus.repository.proxy.ProxyFacetSupport.get(ProxyFacetSupport.java:166) [na:na] at org.sonatype.nexus.repository.proxy.ProxyHandler.handle(ProxyHandler.java:49) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at org.sonatype.nexus.repository.storage.UnitOfWorkHandler.handle(UnitOfWorkHandler.java:39) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at org.sonatype.nexus.repository.view.Context$proceed.call(Unknown Source) [na:na] at com.sonatype.nexus.repository.npm.internal.NpmProxyRecipe$_closure1.doCall(NpmProxyRecipe.groovy:160) [na:na] ... ... Caused by: java.io.IOException: org.apache.shiro.authz.AuthorizationException at com.sonatype.nexus.repository.npm.internal.NpmProxyFacetImpl.retrievePackageRoot(NpmProxyFacetImpl.java:347) [na:na] at com.sonatype.nexus.repository.npm.internal.NpmProxyFacetImpl.retrievePackageVersion(NpmProxyFacetImpl.java:299) [na:na] at com.sonatype.nexus.repository.npm.internal.NpmProxyFacetImpl.getUrl(NpmProxyFacetImpl.java:138) [na:na] ... 131 common frames omitted Caused by: org.apache.shiro.authz.AuthorizationException: null at org.sonatype.nexus.repository.security.SecurityFacetSupport.ensurePermitted(SecurityFacetSupport.java:72) [na:na] at org.sonatype.nexus.repository.security.SecurityHandler.handle(SecurityHandler.java:48) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at org.sonatype.nexus.repository.view.handlers.TimingHandler.handle(TimingHandler.java:46) [na:na] at org.sonatype.nexus.repository.view.Context.proceed(Context.java:80) [na:na] at org.sonatype.nexus.repository.view.Context.start(Context.java:114) [na:na] at org.sonatype.nexus.repository.view.Router.dispatch(Router.java:60) [na:na] at org.sonatype.nexus.repository.view.ConfigurableViewFacet.dispatch(ConfigurableViewFacet.java:52) [na:na] at org.sonatype.nexus.repository.view.ConfigurableViewFacet.dispatch(ConfigurableViewFacet.java:43) [na:na] at com.sonatype.nexus.repository.npm.internal.NpmProxyFacetImpl.retrievePackageRoot(NpmProxyFacetImpl.java:336) [na:na] ... 133 common frames omitted {noformat} *Workaround* If you give that user a read privilege to the proxy _npmjs_ (nx-repository-view-npm-npmjs-read) then the user should be able to install the package that is not already cached. Group level permissions should be transitive, therefore use has the same privileges for all member repositories.

    Sonatype JIRA | 4 months ago | Mahendra Surani
    java.lang.RuntimeException: java.io.IOException: org.apache.shiro.authz.AuthorizationException

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.util.NoSuchElementException

      Iterator depleted

      at org.sonatype.nexus.repository.storage.OrientAsyncHelper$QueueConsumingIterable.next()
    2. org.sonatype.nexus
      OrientAsyncHelper$QueueConsumingIterable.next
      1. org.sonatype.nexus.repository.storage.OrientAsyncHelper$QueueConsumingIterable.next(OrientAsyncHelper.java:202)[na:na]
      2. org.sonatype.nexus.repository.storage.OrientAsyncHelper$QueueConsumingIterable.next(OrientAsyncHelper.java:1)[na:na]
      2 frames
    3. Guava
      TransformedIterator.next
      1. com.google.common.collect.TransformedIterator.next(TransformedIterator.java:47)[com.google.guava:20.0.0]
      1 frame
    4. org.sonatype.nexus
      PurgeUnusedSnapshotsFacetImpl.deleteUnusedSnapshotComponents
      1. org.sonatype.nexus.repository.maven.internal.PurgeUnusedSnapshotsFacetImpl.deleteUnusedSnapshotComponents(PurgeUnusedSnapshotsFacetImpl.java:165)[na:na]
      1 frame