giter8
giter8 copied to clipboard
NullPointerException in ST4 ErrorManager.compileTimeError
steps
sbt or Giter8 version: 0.12.1-SNAPSHOT
❯ /Users/jason/.conscript/bin/g8 BotTech/sbt-autoplugin.g8 -b bottech
sbt plugin seed
pluginName [Foo Bar]: Turtles
name [sbt-turtles]:
organizationName [BotTech]:
organization [nz.co.bottech]:
package [nz.co.bottech.sbt.turtles]:
purpose [An sbt plugin]: An sbt plugin for sharing settings between the meta-builds and the main build.
sbtVersion [1.3.10]:
scalaVersion [2.12.11]:
scalacticVersion [3.1.1]:
uTestVersion [0.7.4]:
problem
The root cause is a SYNTAX ERROR:
'" =~ 2.1[2]..* && "' came as a complete surprise to me
This is then causing a NPE to be thrown when ST4 tries to report the error.
stack trace
java.lang.NullPointerException
at org.stringtemplate.v4.misc.ErrorManager.compileTimeError(ErrorManager.java:100)
at org.stringtemplate.v4.compiler.Compiler.reportMessageAndThrowSTException(Compiler.java:205)
at org.stringtemplate.v4.compiler.Compiler.compile(Compiler.java:149)
at org.stringtemplate.v4.STGroup.compile(STGroup.java:514)
at org.stringtemplate.v4.ST.<init>(ST.java:173)
at giter8.G8$.applyTemplate(g8.scala:134)
at giter8.G8$.write(g8.scala:185)
at giter8.G8$.write(g8.scala:170)
at giter8.G8$.$anonfun$writeTemplates$3(g8.scala:502)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at scala.util.control.Exception$Catch.$anonfun$opt$1(Exception.scala:246)
at scala.util.control.Exception$Catch.apply(Exception.scala:228)
at scala.util.control.Exception$Catch.opt(Exception.scala:246)
at giter8.G8$.$anonfun$writeTemplates$2(g8.scala:502)
at scala.collection.immutable.Stream.foreach(Stream.scala:533)
at giter8.G8$.writeTemplates(g8.scala:488)
at giter8.G8$.$anonfun$applyT$1(g8.scala:344)
at scala.util.Either$RightProjection.flatMap(Either.scala:701)
at giter8.G8$.applyT(g8.scala:327)
at giter8.G8$.fromDirectory(g8.scala:76)
at giter8.G8TemplateRenderer$.render(TemplateRenderer.scala:40)
at giter8.AppProcessor.process(giter8.scala:58)
at giter8.Runner.$anonfun$run$9(Runner.scala:51)
at scala.util.Either.flatMap(Either.scala:341)
at giter8.Runner.$anonfun$run$5(Runner.scala:48)
at scala.util.Either.flatMap(Either.scala:341)
at giter8.Runner.$anonfun$run$4(Runner.scala:47)
at scala.util.Either.flatMap(Either.scala:341)
at giter8.Runner.run(Runner.scala:46)
at giter8.Giter8.run(giter8.scala:33)
at giter8.Giter8.run(giter8.scala:30)
at giter8.Giter8.run(giter8.scala:26)
at giter8.Giter8.run(giter8.scala:22)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:56)
at xsbt.boot.Boot$.main(Boot.scala:18)
at xsbt.boot.Boot.main(Boot.scala)
Unknown exception: null
expectation
notes
A guard was put in ST4 a long time ago but it was not put in all the right places: https://github.com/antlr/stringtemplate4/commit/7bff6cf014408927b1db4b92406996172f8442e5
Should we put our own NPE guard here?
That would be a good idea as a temporary measure. See #461.
@steinybot, how do you think we can proceed? The workaround works, and the PR on ST4 was merged. Can we close it, or is it something else to do? Plus ST4 4.3.1 was released and it was added to giter8 here so technically your fix should now be included.