Skip to content

Commit

Permalink
Fix nullpointer condition on healthcheck (AcademySoftwareFoundation#1412
Browse files Browse the repository at this point in the history
)
  • Loading branch information
DiegoTavares authored Jul 13, 2024
1 parent 15c8d48 commit e54987a
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.imageworks.spcue.servant.CueStatic;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.servlet.FrameworkServlet;

Expand All @@ -45,8 +44,6 @@ public class HealthCheckServlet extends FrameworkServlet {

private static final Logger logger = LogManager.getLogger(HealthCheckServlet.class);
private CueStatic cueStatic;

@Autowired
private Environment env;

private enum HealthStatus {
Expand All @@ -62,6 +59,8 @@ private enum HealthStatus {
public void initFrameworkServlet() throws ServletException {
this.cueStatic = (CueStatic)
Objects.requireNonNull(this.getWebApplicationContext()).getBean("cueStaticServant");
this.env = (Environment)
Objects.requireNonNull(this.getWebApplicationContext()).getBean("environment");
}

private ArrayList<HealthStatus> getHealthStatus() {
Expand Down Expand Up @@ -96,7 +95,7 @@ private ArrayList<HealthStatus> getHealthStatus() {
}

private void getJobs() {
if (this.cueStatic != null) {
if (this.cueStatic != null && this.env != null) {
// Defaults to testing show, which is added as part of the seeding data script
String defaultShow = env.getProperty("protected_shows",
String.class, "testing").split(",")[0];
Expand Down

0 comments on commit e54987a

Please sign in to comment.