Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise exception in case of duplicated trigger in xml #745

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Quartz/Xml/XMLSchedulingDataProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Schema;
using System.Linq;
using System.Xml.Serialization;

using Quartz.Impl.Matchers;
using Quartz.Logging;
using Quartz.Spi;
using Quartz.Util;
using Quartz.Xml.JobSchedulingData20;
using Quartz.Impl.AdoJobStore;

namespace Quartz.Xml
{
Expand Down Expand Up @@ -405,6 +407,13 @@ protected virtual void ProcessInternal(string xml)
}
}

// check for triggers with the same name
var duplicatedTriggers = triggerEntries.GroupBy(c => c.Item.name).Where(c => c.Count() > 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the grouping should be done using name and group? Trigger's identity is based on both name and group.

foreach(var duplicatedEntry in duplicatedTriggers)
{
throw new InvalidConfigurationException("Found duplicated TriggerName: " + duplicatedEntry.Key);
}

Log.Debug("Found " + triggerEntries.Count + " trigger definitions.");

foreach (triggerType triggerNode in triggerEntries)
Expand Down