Move loading of the message's html file after the validity check

This prevents noise in the error_log when the message already expired
and the html file for the message doesn't exist. If the message already
expired then we do not need to load the message's html file.

Change-Id: Id489d8a5282327b2dceab01f6c8a1326d7b7c054
diff --git a/src/main/java/com/googlesource/gerrit/plugins/messageoftheday/GetMessage.java b/src/main/java/com/googlesource/gerrit/plugins/messageoftheday/GetMessage.java
index 255bb90..95bfe2b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/messageoftheday/GetMessage.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/messageoftheday/GetMessage.java
@@ -85,15 +85,6 @@
     }
 
     try {
-      motd.html = new String(Files.readAllBytes(dataDirPath.resolve(motd.id + ".html")), UTF_8);
-    } catch (IOException e1) {
-      log.warn(
-          String.format(
-              "No HTML-file was found for message %s, no message will be shown", motd.id));
-      return Response.none();
-    }
-
-    try {
       String startsAt = cfg.getString(SECTION_MESSAGE, null, KEY_STARTS_AT);
       motd.startsAt = Strings.isNullOrEmpty(startsAt) ? new Date() : DATE_FORMAT.parse(startsAt);
     } catch (ParseException e) {
@@ -101,6 +92,16 @@
     }
 
     if (motd.startsAt.compareTo(new Date()) > 0 || motd.expiresAt.compareTo(new Date()) < 0) {
+      log.debug("Current date/time is outside of the startsAt..expiresAt interval");
+      return Response.none();
+    }
+
+    try {
+      motd.html = new String(Files.readAllBytes(dataDirPath.resolve(motd.id + ".html")), UTF_8);
+    } catch (IOException e1) {
+      log.warn(
+          String.format(
+              "No HTML-file was found for message %s, no message will be shown", motd.id));
       return Response.none();
     }