1

While trying to use micrometer on a Scala project, I got this warning:

[error] While parsing annotations in /Users/vargasmontero/.ivy2/cache/io.micrometer/micrometer-core/jars/micrometer-core-1.0.4.jar(io/micrometer/core/lang/Nullable.class), could not find MAYBE in enum .

It was introduced in 1.0.0-rc.8 but I can't see the release in github.

  • Sbt 1.1.1
  • scala 2.12.5
  • micrometer 1.0.4
James Z
  • 12,209
  • 10
  • 24
  • 44
cvargascr
  • 103
  • 8
  • Can you explain more about not being able to see the release? Also what does your Scala code look like that has the error? – checketts Jun 18 '18 at 11:41
  • A minimal project that has the issue would look like this: In the build file add as dependency: `"io.micrometer" % "micrometer-registry-datadog" % "1.0.4"` Then create a trait using Datadog Config: trait MicrometerRegistryConfig { val config = new DatadogConfig() { override def apiKey(): String = "123" override def step(): Duration = Duration.ZERO override def get(key: String): String = null } } – cvargascr Jun 18 '18 at 14:11
  • i have the same warning but I can't tell if it's causing a problem or not – Cpt. Senkfuss Nov 09 '20 at 13:12

2 Answers2

1

Starting with Scala 2.13.2, configurable warnings can be used to suppress this nuisance with

ThisBuild / scalacOptions ++=
  Seq(
    //<other options omitted>

    // warnings
    "-Wconf:msg=While parsing annotations in:silent"
  )
Jeffrey Aguilera
  • 1,284
  • 11
  • 8
0

I don't have much expertise on Scala but looking into it a bit, Scala doesn't seem to ignore missing meta-annotated classes when it's used on return types (it seems okay when it's used on parameters) unlike Java. Micrometer's @Nullable implementation is the same as the implementation of the Spring framework. So if you use StringUtils.quoteIfString() from the Spring framework, you will see the same warning.

It's a warning, not an error, so you can simply ignore it or if it bothers you, you can add the following optional dependency as a workaround:

libraryDependencies += "com.google.code.findbugs" % "jsr305" % "3.0.2" % Optional

Someone who is a Scala developer might give you a better advice.

FTR this is copied from https://github.com/micrometer-metrics/micrometer/issues/1133#issuecomment-452434205.


UPDATED

I missed the "error" part. You seem to have "-Xfatal-warnings" compiler option.

Johnny Lim
  • 5,623
  • 8
  • 38
  • 53