Skip to content

Commit

Permalink
Limit route priority to 0-9 (#2911)
Browse files Browse the repository at this point in the history
Limit route priority to 0-9
  • Loading branch information
richma-ms authored May 2, 2020
1 parent 4e15050 commit 9cf0203
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
namespace Microsoft.Azure.Devices.Edge.Hub.Core.Config
{
using System;
using System.ComponentModel;
using Microsoft.Azure.Devices.Edge.Util;
using Microsoft.Azure.Devices.Routing.Core;
Expand All @@ -22,8 +23,15 @@ public RouteConfiguration(string route)
public RouteConfiguration(string route, uint priority, uint timeToLiveSecs)
{
this.Route = Preconditions.CheckNonWhiteSpace(route, nameof(route));
this.Priority = priority;
this.TimeToLiveSecs = timeToLiveSecs;

// Verify the route, this must be either between [0-9], or the default value
if ((priority < 0 || priority > 9) && priority != RouteFactory.DefaultPriority)
{
throw new ArgumentOutOfRangeException(nameof(priority), priority, $"Invalid priority for route: {route}, priority can only be between 0-9");
}

this.Priority = priority;
}

[JsonProperty(PropertyName = "route")]
Expand Down

0 comments on commit 9cf0203

Please sign in to comment.