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

Random Stream closed in multiproject build, Detekt 1.19.0, JDK 1.8 #4364

Closed
davidburstrom opened this issue Dec 9, 2021 · 10 comments · Fixed by #4381
Closed

Random Stream closed in multiproject build, Detekt 1.19.0, JDK 1.8 #4364

davidburstrom opened this issue Dec 9, 2021 · 10 comments · Fixed by #4381
Labels

Comments

@davidburstrom
Copy link
Contributor

Ran on JDK 1.8, analysing multiple modules in parallel. Probably the standard issue with reusing cached zip streams within the same VM.

Caused by: java.io.IOException: Stream closed
at io.gitlab.arturbosch.detekt.core.config.ValidateConfigKt.validateConfig$getDeprecatedProperties(ValidateConfig.kt:71)$
at io.gitlab.arturbosch.detekt.core.config.ValidateConfigKt.validateConfig$testKeys(ValidateConfig.kt:83)$
at io.gitlab.arturbosch.detekt.core.config.ValidateConfigKt.validateConfig$testKeys(ValidateConfig.kt:107)$
at io.gitlab.arturbosch.detekt.core.config.ValidateConfigKt.validateConfig$testKeys(ValidateConfig.kt:107)$
at io.gitlab.arturbosch.detekt.core.config.ValidateConfigKt.validateConfig(ValidateConfig.kt:113)$
at io.gitlab.arturbosch.detekt.core.config.ValidateConfigKt.validateConfig(ValidateConfig.kt:34)$
at io.gitlab.arturbosch.detekt.core.config.CompositeConfig.validate(CompositeConfig.kt:31)$
at io.gitlab.arturbosch.detekt.core.config.ValidateConfigKt.validateConfig(ValidateConfig.kt:114)$
at io.gitlab.arturbosch.detekt.core.config.ValidateConfigKt.validateConfig(ValidateConfig.kt:34)$
at io.gitlab.arturbosch.detekt.core.config.DefaultPropertiesConfigValidator.validate(DefaultPropertiesConfigValidator.kt:24)$
at io.gitlab.arturbosch.detekt.core.config.ConfigValidatorsKt.checkConfiguration(ConfigValidators.kt:18)$
at io.gitlab.arturbosch.detekt.core.tooling.Lifecycle$analyze$1.invoke(Lifecycle.kt:35)$
at io.gitlab.arturbosch.detekt.core.tooling.Lifecycle$analyze$1.invoke(Lifecycle.kt:35)$
at io.gitlab.arturbosch.detekt.core.util.PerformanceMonitor.measure(PerformanceMonitor.kt:42)$
at io.gitlab.arturbosch.detekt.core.tooling.Lifecycle$DefaultImpls.measure(Lifecycle.kt:32)$
at io.gitlab.arturbosch.detekt.core.tooling.Lifecycle$DefaultImpls.analyze(Lifecycle.kt:35)$
at io.gitlab.arturbosch.detekt.core.tooling.DefaultLifecycle.analyze(Lifecycle.kt:59)$
at io.gitlab.arturbosch.detekt.core.tooling.AnalysisFacade$runAnalysis$1.invoke(AnalysisFacade.kt:43)$
at io.gitlab.arturbosch.detekt.core.tooling.AnalysisFacade$runAnalysis$1.invoke(AnalysisFacade.kt:42)$
at io.gitlab.arturbosch.detekt.core.tooling.ProcessingSpecSettingsBridgeKt.withSettings(ProcessingSpecSettingsBridge.kt:26)$
at io.gitlab.arturbosch.detekt.core.tooling.AnalysisFacade.runAnalysis$detekt_core(AnalysisFacade.kt:42)$
at io.gitlab.arturbosch.detekt.core.tooling.AnalysisFacade.run(AnalysisFacade.kt:25)$
at io.gitlab.arturbosch.detekt.cli.runners.Runner.call(Runner.kt:33)$
at io.gitlab.arturbosch.detekt.cli.runners.Runner.execute(Runner.kt:23)$
at io.gitlab.arturbosch.detekt.invoke.DefaultCliInvoker.invokeCli(DetektInvoker.kt:59)$
at io.gitlab.arturbosch.detekt.Detekt.check(Detekt.kt:252)$
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)$

Your Environment

  • JDK 1.8
  • Version of Detekt used: 1.19.0
  • Version of Gradle used (if applicable): 7.3.1
  • Operating System and version: macOS Monterey
@davidburstrom davidburstrom changed the title Random Stream closed in multiproject build, Detek 1.19.0, JDK 1.8 Random Stream closed in multiproject build, Detekt 1.19.0, JDK 1.8 Dec 9, 2021
@cortinico
Copy link
Member

Ran on JDK 1.8, analysing multiple modules in parallel

Which type of parallelism are you using? Gradle parallel execution or Detekt --parallel?
Also is this happening only on JDK 8 or also on other JDKs?

@davidburstrom
Copy link
Contributor Author

My special parallel execution :) Detekt loaded and executed by isolated class loaders in parallel.

@cortinico
Copy link
Member

My special parallel execution :) Detekt loaded and executed by isolated class loaders in parallel.

Gotcha. I'm unsure what we can do to address this bug then. Any idea?

@davidburstrom
Copy link
Contributor Author

I'll sound like a broken record, but it's the same solution as always: instead of calling getResourceAsStream(), call getResource() and open the URL connection with caches turned off.

@BraisGabin
Copy link
Member

Then I think that this issue is fixed in 1.20.0 by #4334. Could you try the last SNAPSHOT? We shouldn't have any call to getResourceAsStream now.

@davidburstrom
Copy link
Contributor Author

That looks really promising indeed!

@davidburstrom
Copy link
Contributor Author

Ah, still breaks:

return settings.javaClass.classLoader.getResourceAsStream("deprecation.properties")!!.use { inputStream ->

You also need to look for ClassLoader.getResourceAsStream()

@BraisGabin
Copy link
Member

Added that function too as forbidden and use the safe one.

@davidburstrom
Copy link
Contributor Author

As far as I can tell, the latest snapshot fixed the problem. Thanks!

@BraisGabin
Copy link
Member

Thank you to keep pushing to fix this. It take a while but let's hope that it'd fixed for good now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants