1818import io .jooby .ServiceRegistry ;
1919
2020import javax .annotation .Nonnull ;
21+ import java .io .IOException ;
2122import java .util .ArrayList ;
2223import java .util .HashSet ;
2324import java .util .LinkedHashMap ;
@@ -235,8 +236,6 @@ public void install(@Nonnull Jooby application) {
235236 final Set <Reporter > reporters = new HashSet <>();
236237
237238 application .onStarted (() -> {
238- Config config = application .getConfig ();
239-
240239 metrics .forEach ((name , instance ) -> {
241240 registry .putIfAbsent (ServiceKey .key (Metric .class , name ), instance );
242241 metricRegistry .register (name , instance );
@@ -259,12 +258,20 @@ public void install(@Nonnull Jooby application) {
259258 healthCheckRegistry .register (name , instance );
260259 });
261260
261+ Config config = application .getConfig ();
262+
262263 this .reporters .stream ()
263264 .map (r -> r .apply (metricRegistry , config ))
264265 .filter (Objects ::nonNull )
265266 .forEachOrdered (reporters ::add );
266267 });
267268
268- application .onStop (() -> reporters .forEach (throwingConsumer (Reporter ::close )));
269+ application .onStop (() -> reporters .forEach (r -> {
270+ try {
271+ r .close ();
272+ } catch (IOException e ) {
273+ application .getLog ().error ("close of {} resulted in error" , r , e );
274+ }
275+ }));
269276 }
270277}
0 commit comments