Skip to content

Commit

Permalink
Avoid NPE sending email on dev machines (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-jeckels authored Aug 23, 2024
1 parent b415cca commit 7af51ed
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions testresults/src/org/labkey/testresults/SendTestResultsEmail.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.data.Container;
import org.labkey.api.data.ContainerManager;
import org.labkey.api.data.TableSelector;
Expand All @@ -14,6 +15,7 @@
import org.labkey.api.util.MimeMap;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.api.util.Pair;
import org.labkey.api.util.UnexpectedException;
import org.labkey.api.view.ActionURL;
import org.labkey.testresults.model.BackgroundColor;
import org.labkey.testresults.model.RunDetail;
Expand Down Expand Up @@ -335,15 +337,19 @@ public void execute(String ctx, org.labkey.api.security.User from, String emailT
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException
{
ValidEmail admin = null;
ValidEmail admin;
try
{
admin = new ValidEmail(DEFAULT_EMAIL.ADMIN_EMAIL);
org.labkey.api.security.@Nullable User adminUser = UserManager.getUser(admin);
if (adminUser != null)
{
execute(MORNING_EMAIL, adminUser, DEFAULT_EMAIL.RECIPIENT);
}
}
catch (ValidEmail.InvalidEmailException e)
{
e.printStackTrace();
throw UnexpectedException.wrap(e);
}
execute(MORNING_EMAIL, UserManager.getUser(admin), DEFAULT_EMAIL.RECIPIENT);
}
}

0 comments on commit 7af51ed

Please sign in to comment.