Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileSystemAlreadyExistsException when recordBanner is run in parallel #7689

Closed
ppalaga opened this issue Mar 9, 2020 · 15 comments · Fixed by #7693
Closed

FileSystemAlreadyExistsException when recordBanner is run in parallel #7689

ppalaga opened this issue Mar 9, 2020 · 15 comments · Fixed by #7693
Labels
kind/bug Something isn't working
Milestone

Comments

@ppalaga
Copy link
Contributor

ppalaga commented Mar 9, 2020

Some of us use mvnd to build Camel Quarkus. Mvnd builds the modules in parallel by default. The recently added BannerProcessor.recordBanner() does not seem to be prepared for that because it throws the following exception when an application is built with mvnd:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal �[32mio.quarkus:quarkus-maven-plugin:1.3.0.CR1:build�[m �[1m(default)�[m on project �[36mcamel-quarkus-integration-test-stream�[m: �[1;31mFailed to build quarkus application�[m
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
	at org.jboss.fuse.mvnd.builder.SmartBuilderImpl.buildProject(SmartBuilderImpl.java:176)
	at org.jboss.fuse.mvnd.builder.SmartBuilderImpl$ProjectBuildTask.run(SmartBuilderImpl.java:196)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to build quarkus application
	at io.quarkus.maven.BuildMojo.execute(BuildMojo.java:185)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
	... 10 common frames omitted
Caused by: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.deployment.steps.BannerProcessor#recordBanner threw an exception: java.nio.file.FileSystemAlreadyExistsException
	at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:113)
	at java.nio.file.FileSystems.newFileSystem(FileSystems.java:326)
	at java.nio.file.FileSystems.newFileSystem(FileSystems.java:276)
	at io.quarkus.deployment.steps.BannerProcessor.isQuarkusCoreBanner(BannerProcessor.java:111)
	at io.quarkus.deployment.steps.BannerProcessor.getBanner(BannerProcessor.java:93)
	at io.quarkus.deployment.steps.BannerProcessor.readBannerFile(BannerProcessor.java:53)
	at io.quarkus.deployment.steps.BannerProcessor.recordBanner(BannerProcessor.java:42)
	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 io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:938)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:273)
	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2027)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1551)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1442)
	at java.lang.Thread.run(Thread.java:748)
	at org.jboss.threads.JBossThread.run(JBossThread.java:479)

	at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:206)
	at io.quarkus.runner.bootstrap.AugmentActionImpl.createProductionApplication(AugmentActionImpl.java:77)
	at io.quarkus.maven.BuildMojo.execute(BuildMojo.java:172)
	... 12 common frames omitted
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.deployment.steps.BannerProcessor#recordBanner threw an exception: java.nio.file.FileSystemAlreadyExistsException
	at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:113)
	at java.nio.file.FileSystems.newFileSystem(FileSystems.java:326)
	at java.nio.file.FileSystems.newFileSystem(FileSystems.java:276)
	at io.quarkus.deployment.steps.BannerProcessor.isQuarkusCoreBanner(BannerProcessor.java:111)
	at io.quarkus.deployment.steps.BannerProcessor.getBanner(BannerProcessor.java:93)
	at io.quarkus.deployment.steps.BannerProcessor.readBannerFile(BannerProcessor.java:53)
	at io.quarkus.deployment.steps.BannerProcessor.recordBanner(BannerProcessor.java:42)
	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 io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:938)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:273)
	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2027)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1551)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1442)
	at java.lang.Thread.run(Thread.java:748)
	at org.jboss.threads.JBossThread.run(JBossThread.java:479)

	at io.quarkus.builder.Execution.run(Execution.java:115)
	at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
	at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:135)
	at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:204)
	... 14 common frames omitted
Caused by: java.nio.file.FileSystemAlreadyExistsException: null
	at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:113)
	at java.nio.file.FileSystems.newFileSystem(FileSystems.java:326)
	at java.nio.file.FileSystems.newFileSystem(FileSystems.java:276)
	at io.quarkus.deployment.steps.BannerProcessor.isQuarkusCoreBanner(BannerProcessor.java:111)
	at io.quarkus.deployment.steps.BannerProcessor.getBanner(BannerProcessor.java:93)
	at io.quarkus.deployment.steps.BannerProcessor.readBannerFile(BannerProcessor.java:53)
	at io.quarkus.deployment.steps.BannerProcessor.recordBanner(BannerProcessor.java:42)
	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 io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:938)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:273)
	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2027)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1551)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1442)
	at java.lang.Thread.run(Thread.java:748)
	at org.jboss.threads.JBossThread.run(JBossThread.java:479)

Steps to reproduce:

  1. clone, build and add mvnd to PATH as described on https://github.com/gnodet/mvnd
  2. Build recent Camel Quarkus (based on Quarkus 1.3.0.CR1) with mvnd:
git clone https://github.com/apache/camel-quarkus.git
cd camel-quarkus
mvnd clean install -DskipTests -e

Alternatively, this issue can be reproduced with stock Maven using -T C1 in Camel Quarkus:

mvn clean install -DskipTests -e -T C1

When I run the above Maven command in Quarkus, I am getting a different unrelated error.

cc @geoand

@ppalaga ppalaga added the kind/bug Something isn't working label Mar 9, 2020
@ppalaga
Copy link
Contributor Author

ppalaga commented Mar 9, 2020

@geoand I wonder whether we could find out isQuarkusCoreBanner without opening the JAR? E.g. by matching the URL string against a RegExp?

@geoand
Copy link
Contributor

geoand commented Mar 9, 2020

So, there is no good (as in "won't break if things are refactored") way of knowing if the banner is the default or not without opening the JAR. On the other hand, in most cases I don't think we really care, so we could just ignore the error and return false.

@maxandersen WDYT?

@ppalaga
Copy link
Contributor Author

ppalaga commented Mar 9, 2020

If you really need to read the JAR, java.util.jar.JarFile could be a solution.

@ppalaga
Copy link
Contributor Author

ppalaga commented Mar 9, 2020

Some locking and caching of the default URL could help too ppalaga@196a6dd

@geoand
Copy link
Contributor

geoand commented Mar 9, 2020

TBH, I really don't want to go to all that complexity just to support parallel builds...

@geoand
Copy link
Contributor

geoand commented Mar 9, 2020

But you can go ahead and create a PR with your change, I won't block it :)

@ppalaga
Copy link
Contributor Author

ppalaga commented Mar 9, 2020

Reducing the build times to 1/3 is a strong motivation.

@gsmet
Copy link
Member

gsmet commented Mar 9, 2020

Yeah, we should seriously consider doing something. We are breaking some people's workflow to display a banner. So maybe we can fix that and keep those people happy?

If knowing if it's the default is only used to display the Powered by Quarkus that is displayed just a line below, maybe we can just drop it?

Does someone really think it's a compelling enough reason to break someone's workflow?

@geoand
Copy link
Contributor

geoand commented Mar 9, 2020

I already mentioned above that we can display it and be done with it instead of adding caching / synchronization code

@gsmet
Copy link
Member

gsmet commented Mar 9, 2020

Why don't we just check if the path has been changed in the config?

Agreed, it's not as accurate but it would be far simpler and less convoluted and would work most of the time.

@geoand
Copy link
Contributor

geoand commented Mar 9, 2020

Why don't we just check if the path has been changed in the config?

That was the initial implementation. It was changed because a user could add their own banner that uses the same name - and in this case we do want to show the Powered by line.

Agreed, it's not as accurate but it would be far simpler and less convoluted and would work most of the time.

As everything in life, it depends. If you want it to always be correct, you need to do what has been done here.
But I completely agree that we can just display the line if the a FileSystemAlreadyExists exception is thrown and be done with it once and for all.

@gsmet
Copy link
Member

gsmet commented Mar 9, 2020

That was the initial implementation. It was changed because a user could add their own banner that uses the same name - and in this case we do want to show the Powered by line.

I think it's perfectly acceptable. It's not as if it was critical. You have Powered by Quarkus displayed one line below...

That simplifies things a lot and avoids this issue.

@geoand
Copy link
Contributor

geoand commented Mar 9, 2020

Sure, but them someone else will come back and ask for the feature. So we need a final decision on this.

To be clear, my proposal is to the logic as is and just return false when FileSystemAlreadyExists is thrown

@geoand
Copy link
Contributor

geoand commented Mar 9, 2020

Give me a couple minutes to open a PR that @ppalaga can check

@geoand
Copy link
Contributor

geoand commented Mar 9, 2020

@ppalaga can you try #7693 please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants