Propose to swap this clauses. If mnd.getMetricName() == null then you will get NPE here.