apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.67k stars 855 forks source link

AssertionError in OfflineConnector (maven embedder) #3904

Open ebarboni opened 2 years ago

ebarboni commented 2 years ago

Apache NetBeans version

Apache NetBeans 13

What happened

AssertionError happens sometime and is :

stacktrace:


java.lang.AssertionError
    at org.netbeans.modules.maven.embedder.impl.OfflineConnector.newInstance(OfflineConnector.java:43)
    at org.eclipse.aether.internal.impl.DefaultRepositoryConnectorProvider.newRepositoryConnector(DefaultRepositoryConnectorProvider.java:107)
    at org.eclipse.aether.internal.impl.DefaultMetadataResolver$ResolveTask.run(DefaultMetadataResolver.java:584)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)
    at org.eclipse.aether.internal.impl.DefaultMetadataResolver$1.execute(DefaultMetadataResolver.java:510)
    at org.eclipse.aether.internal.impl.DefaultMetadataResolver.resolve(DefaultMetadataResolver.java:353)
    at org.eclipse.aether.internal.impl.DefaultMetadataResolver.resolveMetadata(DefaultMetadataResolver.java:181)
    at org.apache.maven.repository.internal.DefaultVersionResolver.resolveVersion(DefaultVersionResolver.java:213)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:282)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:229)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:207)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:262)
    at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:215)
    at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
    at org.apache.maven.repository.legacy.LegacyRepositorySystem.resolve(LegacyRepositorySystem.java:367)
    at org.netbeans.modules.maven.embedder.MavenEmbedder.resolve(MavenEmbedder.java:378)
    at org.netbeans.modules.maven.embedder.NBRepositoryModelResolver.resolveModel(NBRepositoryModelResolver.java:74)
    at org.netbeans.modules.maven.embedder.NBRepositoryModelResolver.resolveModel(NBRepositoryModelResolver.java:88)
    at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally(DefaultModelBuilder.java:1077)
    at org.apache.maven.model.building.DefaultModelBuilder.readParent(DefaultModelBuilder.java:853)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:344)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:252)
    at org.netbeans.modules.maven.embedder.impl.NBModelBuilder.build(NBModelBuilder.java:53)
    at org.netbeans.modules.maven.embedder.MavenEmbedder.executeModelBuilder(MavenEmbedder.java:447)
    at org.netbeans.modules.maven.NbMavenProjectImpl.getRawModel(NbMavenProjectImpl.java:199)
    at org.netbeans.modules.maven.api.NbMavenProject.getRawModel(NbMavenProject.java:372)
    at org.netbeans.modules.maven.MavenProjectPropsImpl.lambda$get$0(MavenProjectPropsImpl.java:93)
    at org.netbeans.modules.openide.util.DefaultMutexImplementation.readAccess(DefaultMutexImplementation.java:188)
    at org.openide.util.Mutex.readAccess(Mutex.java:199)
    at org.netbeans.modules.maven.MavenProjectPropsImpl.get(MavenProjectPropsImpl.java:78)
    at org.netbeans.modules.maven.MavenProjectPropsImpl.get(MavenProjectPropsImpl.java:74)
    at org.netbeans.modules.maven.MavenProjectPropsImpl$PackagingProviderImpl.packaging(MavenProjectPropsImpl.java:306)
    at org.netbeans.modules.maven.api.NbMavenProject.getPackagingType(NbMavenProject.java:359)
    at org.netbeans.modules.maven.NbMavenProjectImpl$PackagingTypeDependentLookup.check(NbMavenProjectImpl.java:921)
    at org.netbeans.modules.maven.NbMavenProjectImpl$PackagingTypeDependentLookup.<init>(NbMavenProjectImpl.java:880)
    at org.netbeans.modules.maven.NbMavenProjectImpl.<init>(NbMavenProjectImpl.java:257)
    at org.netbeans.modules.maven.NbMavenProjectFactory.loadProject(NbMavenProjectFactory.java:95)
    at org.netbeans.modules.projectapi.nb.NbProjectManager.createProject(NbProjectManager.java:376)
    at org.netbeans.modules.projectapi.nb.NbProjectManager.access$300(NbProjectManager.java:69)
    at org.netbeans.modules.projectapi.nb.NbProjectManager$2.run(NbProjectManager.java:289)
    at org.netbeans.modules.projectapi.nb.NbProjectManager$2.run(NbProjectManager.java:218)
    at org.netbeans.modules.openide.util.DefaultMutexImplementation.readAccess(DefaultMutexImplementation.java:188)
    at org.openide.util.Mutex.readAccess(Mutex.java:231)
    at org.netbeans.modules.projectapi.nb.NbProjectManager.findProject(NbProjectManager.java:218)
    at org.netbeans.api.project.ProjectManager.findProject(ProjectManager.java:142)
    at org.netbeans.modules.projectapi.SimpleFileOwnerQueryImplementation.getOwner(SimpleFileOwnerQueryImplementation.java:144)
    at org.netbeans.modules.projectapi.SimpleFileOwnerQueryImplementation.getOwner(SimpleFileOwnerQueryImplementation.java:93)
    at org.netbeans.api.project.FileOwnerQuery.getOwner(FileOwnerQuery.java:125)
    at org.netbeans.modules.projectapi.ProjectSharabilityQuery2.getSharability(ProjectSharabilityQuery2.java:40)
    at org.netbeans.api.queries.SharabilityQuery.getSharability(SharabilityQuery.java:152)
    at org.netbeans.modules.git.utils.GitUtils.isIgnored(GitUtils.java:227)
    at org.netbeans.modules.git.FileStatusCache$IgnoredFilesHandler.run(FileStatusCache.java:851)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
    at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
    at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)

How to reproduce

Unable to reproduce. issue just appears time to time. I have maven project opened. I have no clue to propose a PR.

Did this work correctly in an earlier version?

Apache NetBeans 12.6

Operating System

Windows 11

JDK

jdk17

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

No response

Are you willing to submit a pull request?

No

Code of Conduct

Yes

lkishalmi commented 2 years ago

Seems strange as assertions shall be switched off on release builds...

sdedic commented 2 years ago

Hm, I work on some dependency analysis code. The AssertionError does not actually originate from an assert statement, but from an explicit throw that uses AssertionError to escape from all exc handling frames in Maven and abort. It happens when maven attempts to connect to a remote repository despite its session is set to read only. There are isOffline checks throughout the resolvers, that should prevent the connection attempt complete (and fail with a different exception), but they not trigger for some reason.

I am still not clear on why this thing even happens. It happens when the project references an artifact not in the local repository - but not always. Tends to happen more when the shared EmbedderFactory.getProjectEmbedder() shared embedder is used.

ebarboni commented 2 years ago

Adding another type of stack. But it happens so infrequently that is impossible to fix.

SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor org.netbeans.modules.git.FilesystemInterceptor$RefreshTask
java.lang.AssertionError
    at org.netbeans.modules.maven.embedder.impl.OfflineConnector.newInstance(OfflineConnector.java:43)
    at org.eclipse.aether.internal.impl.DefaultRepositoryConnectorProvider.newRepositoryConnector(DefaultRepositoryConnectorProvider.java:107)
    at org.eclipse.aether.internal.impl.DefaultMetadataResolver$ResolveTask.run(DefaultMetadataResolver.java:584)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
ebarboni commented 2 years ago

I get this back on NetBeans 15