Fixed crash on start when metrics not specified
package com.artipie;
-import com.amihaiemil.eoyaml.YamlMapping;
import com.artipie.http.Pie;
import com.artipie.http.Slice;
import com.artipie.metrics.Metrics;
@@ -138,9 +137,14 @@ public final class VertxMain implements Runnable {
* @throws IOException In case of I/O error reading settings.
*/
private static Metrics metrics(final Settings settings) throws IOException {
- final YamlMapping root = settings.meta().yamlMapping("metrics");
- return Optional.ofNullable(root.string("type")).<Metrics>map(
- type -> {
+ return Optional.ofNullable(settings.meta())
+ .map(meta -> meta.yamlMapping("metrics"))
+ .<Metrics>map(
+ root -> {
+ final String type = root.string("type");
+ if (type == null) {
+ throw new IllegalArgumentException("Metrics type is not specified");
+ }
if (!type.equals("log")) {
throw new IllegalArgumentException(
String.format("Unsupported metrics type: %s", type)
