m-m-m / code

Library to parse, analyze, transform and generate code
Apache License 2.0
2 stars 3 forks source link

Illegal state exception if local repository folder does not exist #43

Closed maybeec closed 1 year ago

maybeec commented 1 year ago

Steps to reproduce

  1. Make sure your local default repository path does not exist
  2. Instantiate MavenBridgeImpl

Actual behavior

We have such behavior in CobiGen on the CI/CD resulting in the following stack trace. We don't use the default maven repository as of github/cache usage across OS. - different story :) It seems, that MavenBridgeImpl is actually requiring the folder to exist, which will end in an IllegalStateException exception. This is even more stupid as it also occurs in case you are instantiating the MavenBridgeImpl properly with a valid repository path.

10:46:32.281 [Thread-2] INFO  c.d.c.c.s.G.cliprocess - java.lang.ExceptionInInitializerError: null
10:46:32.281 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at com.devonfw.cobigen.javaplugin.inputreader.JavaParserUtil.getJavaContext(JavaParserUtil.java:128)
10:46:32.281 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at com.devonfw.cobigen.javaplugin.inputreader.JavaInputReader.createParsedClassLoader(JavaInputReader.java:451)
10:46:32.281 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at com.devonfw.cobigen.javaplugin.inputreader.JavaInputReader.read(JavaInputReader.java:394)
10:46:32.281 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at com.devonfw.cobigen.impl.generator.InputInterpreterImpl.readInput(InputInterpreterImpl.java:96)
10:46:32.281 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at com.devonfw.cobigen.impl.generator.InputInterpreterImpl.read(InputInterpreterImpl.java:70)
10:46:32.281 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
10:46:32.281 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
10:46:32.281 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
10:46:32.281 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at java.base/java.lang.reflect.Method.invoke(Method.java:566)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at com.devonfw.cobigen.api.util.ExceptionUtil.invokeTarget(ExceptionUtil.java:73)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at com.devonfw.cobigen.impl.aop.CachedInterceptor.invoke(CachedInterceptor.java:41)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at com.sun.proxy.$Proxy16.read(Unknown Source)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at com.devonfw.cobigen.impl.generator.CobiGenImpl.read(CobiGenImpl.java:170)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at com.devonfw.cobigen.cli.commands.GenerateCommand.preprocess(GenerateCommand.java:204)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at com.devonfw.cobigen.cli.commands.GenerateCommand.doAction(GenerateCommand.java:130)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at com.devonfw.cobigen.cli.commands.CommandCommons.call(CommandCommons.java:42)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at com.devonfw.cobigen.cli.commands.CommandCommons.call(CommandCommons.java:15)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at picocli.CommandLine.access$1500(CommandLine.java:148)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at picocli.CommandLine.execute(CommandLine.java:2170)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at com.devonfw.cobigen.cli.CobiGenCLI.main(CobiGenCLI.java:37)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess - Caused by: java.lang.IllegalStateException: Directory not found: /home/runner/.m2/repository
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at io.github.mmm.code.java.maven.impl.MavenResolver.<init>(MavenResolver.java:45)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at io.github.mmm.code.java.maven.impl.MavenBridgeImpl.<init>(MavenBridgeImpl.java:72)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at io.github.mmm.code.java.maven.impl.MavenBridgeImpl.<init>(MavenBridgeImpl.java:56)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  at io.github.mmm.code.java.maven.impl.MavenBridgeImpl.<clinit>(MavenBridgeImpl.java:45)
10:46:32.282 [Thread-2] INFO  c.d.c.c.s.G.cliprocess -  ... 26 common frames omitted

Expected behavior

Affected version

maybeec commented 1 year ago

For reference, the github actions run: https://github.com/devonfw/cobigen/actions/runs/4005050174/jobs/6875112523#step:7:8933

hohwille commented 1 year ago

@maybeec thanks for reporting. Indeed stupid that default instance was initialized eagerly causing the error. Fixed.

maybeec commented 1 year ago

Mh no, I didn't put any special configuration in place to hinder you editing the pr... Strange

hohwille commented 1 year ago

For the record 0.9.2 has been released some time ago. https://repo1.maven.org/maven2/io/github/m-m-m/mmm-code-java-impl/0.9.2/ If you wonder why you cannot see the 0.9.2 in the artifact folders like here: https://repo1.maven.org/maven2/io/github/m-m-m/mmm-code-java-impl This is a OSSRH issue (https://issues.sonatype.org/browse/OSSRH-92124)