@Override
  @CheckForNull
  public String message(Locale locale, String key, @Nullable String defaultValue, Object... parameters) {
    String bundleKey = propertyToBundles.get(key);
    String value = null;
    if (bundleKey != null) {
      try {
        ResourceBundle resourceBundle = ResourceBundle.getBundle(bundleKey, locale, classloader, control);
        value = resourceBundle.getString(key);
      } catch (MissingResourceException e1) {
        // ignore
      }
    }
    if (value == null) {
      value = defaultValue;
    }
    return formatMessage(value, parameters);
  }
@Test
  public void all_core_metrics_are_in_core_bundle() {
    List<Metric> coreMetrics = CoreMetrics.getMetrics();
    List<String> incorrectMetricDefinitions = new ArrayList<>();
    for (Metric metric : coreMetrics) {
      if (metric.isHidden()) {
        continue;
      }
      String metricNamePropertyKey = "metric." + metric.getKey() + ".name";
      String l10nMetricName = underTest.message(Locale.ENGLISH, metricNamePropertyKey, null);
      if (l10nMetricName == null) {
        incorrectMetricDefinitions.add(metricNamePropertyKey + "=" + metric.getName());
      } else if (!l10nMetricName.equals(metric.getName())) {
        incorrectMetricDefinitions.add(metricNamePropertyKey + " is not consistent in core bundle and CoreMetrics");
      }

      String metricDescriptionPropertyKey = "metric." + metric.getKey() + ".description";
      String l10nMetricDescription = underTest.message(Locale.ENGLISH, metricDescriptionPropertyKey, null);
      if (l10nMetricDescription == null) {
        incorrectMetricDefinitions.add(metricDescriptionPropertyKey + "=" + metric.getDescription());
      } else if (!l10nMetricDescription.equals(metric.getDescription())) {
        incorrectMetricDefinitions.add(metricDescriptionPropertyKey + " is not consistent in core bundle and CoreMetrics");
      }
    }

    assertThat(incorrectMetricDefinitions).as("Metric definitions to fix in core bundle", incorrectMetricDefinitions.size()).isEmpty();
  }