xolstice / protobuf-maven-plugin

Maven Plugin that executes the Protocol Buffers (protoc) compiler
https://www.xolstice.org/protobuf-maven-plugin/
Other
236 stars 78 forks source link

"Plugin output is unparseable" when the JVM outputs warnings #104

Open raboof opened 2 years ago

raboof commented 2 years ago

Is your feature request related to a problem? Please describe.

It is possible for the JVM to output warnings using their "Unified Logging" framework.

For example, when using Java 17, if there are duplicate 'cpuset controllers' you will see a warning about that:

[0.001s][warning][os,container] Duplicate cpuset controllers detected. Picking /sys/fs/cgroup/cpuset, skipping /host/sys/fs/cgroup/cpuset.
openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment (build 17.0.3+7-nixos)
OpenJDK 64-Bit Server VM (build 17.0.3+7-nixos, mixed mode, sharing)

Unfortunately, by default, these warnings are printed to stdout. This means when protoc tries to parse the output of a JVM-based protoc plugin, and the JVM prints such a warning, the output is invalid and you will get a "Plugin output is unparseable" error.

Describe the solution you'd like

I would like the default JVM startup scripts (created by ProtocPluginAssembler) to, by default, invoke the JVM with the extra JVM options: -Xlog:disable -Xlog:all=warning:stderr -Xlog:all=error:sterr. -Xlog:disable should stop it from printing warnings to stdout, and -Xlog:all=warning:stderr should AFAICS cause it to print warnings to stderr. In practice unfortunately my JDK17 doesn't actually print them to stderr, but that seems to be a bug on the JVM side and I'm not sure we should care about it.