Skip to content

Commit

Permalink
Fix NullPointerException
Browse files Browse the repository at this point in the history
  • Loading branch information
PeteGoo committed Mar 4, 2015
1 parent 100ef2b commit e5603c3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import slacknotifications.SlackNotification;
import slacknotifications.teamcity.payload.SlackNotificationPayloadManager;
import slacknotifications.teamcity.settings.SlackNotificationConfig;
import slacknotifications.teamcity.settings.SlackNotificationContentConfig;
import slacknotifications.teamcity.settings.SlackNotificationMainSettings;
import slacknotifications.teamcity.settings.SlackNotificationProjectSettings;

Expand Down Expand Up @@ -74,20 +75,20 @@ public void getFromConfig(SlackNotification slackNotification, SlackNotification
slackNotification.setShowElapsedBuildTime(myMainSettings.getShowElapsedBuildTime());
slackNotification.setShowCommits(myMainSettings.getShowCommits());
slackNotification.setShowCommitters(myMainSettings.getShowCommitters());
slackNotification.setShowFailureReason(myMainSettings.getShowFailureReason());
slackNotification.setShowFailureReason(myMainSettings.getShowFailureReason() == null ? SlackNotificationContentConfig.DEFAULT_SHOW_FAILURE_REASON : myMainSettings.getShowFailureReason());
slackNotification.setMaxCommitsToDisplay(myMainSettings.getMaxCommitsToDisplay());
slackNotification.setMentionChannelEnabled(slackNotificationConfig.getMentionChannelEnabled());
slackNotification.setMentionSlackUserEnabled(slackNotificationConfig.getMentionSlackUserEnabled());
slackNotification.setShowElapsedBuildTime(myMainSettings.getShowFailureReason());
if(slackNotificationConfig.getContent().isEnabled()) {
slackNotification.setShowElapsedBuildTime(myMainSettings.getShowElapsedBuildTime());
if(slackNotificationConfig.getContent() != null && slackNotificationConfig.getContent().isEnabled()) {
slackNotification.setBotName(slackNotificationConfig.getContent().getBotName());
slackNotification.setIconUrl(slackNotificationConfig.getContent().getIconUrl());
slackNotification.setMaxCommitsToDisplay(slackNotificationConfig.getContent().getMaxCommitsToDisplay());
slackNotification.setShowBuildAgent(slackNotificationConfig.getContent().getShowBuildAgent());
slackNotification.setShowElapsedBuildTime(slackNotificationConfig.getContent().getShowElapsedBuildTime());
slackNotification.setShowCommits(slackNotificationConfig.getContent().getShowCommits());
slackNotification.setShowCommitters(slackNotificationConfig.getContent().getShowCommitters());
slackNotification.setShowFailureReason(slackNotificationConfig.getContent().getShowFailureReason());
slackNotification.setShowFailureReason(slackNotificationConfig.getContent().getShowFailureReason() == null ? SlackNotificationContentConfig.DEFAULT_SHOW_FAILURE_REASON : slackNotificationConfig.getContent().getShowFailureReason());
}
Loggers.ACTIVITIES.debug("SlackNotificationListener :: SlackNotification proxy set to "
+ slackNotification.getProxyHost() + " for " + slackNotificationConfig.getChannel());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public class SlackNotificationPayloadContent {
private String color;
private long elapsedTime;
private boolean isComplete;
private ArrayList<String> failedBuildMessages;
private ArrayList<String> failedTestNames;
private ArrayList<String> failedBuildMessages = new ArrayList<String>();
private ArrayList<String> failedTestNames = new ArrayList<String>();

public SlackNotificationPayloadContent(){

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,9 @@ public SlackNotificationProxyConfig getProxyConfig() {
}

public SlackNotificationContentConfig getContent() {
if(content == null){
this.content = new SlackNotificationContentConfig();
}
return content;
}
}

0 comments on commit e5603c3

Please sign in to comment.