-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check string utf8 byte size instead of string length
- Loading branch information
1 parent
c0d1471
commit 7a3f2e9
Showing
1 changed file
with
4 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
using System; | ||
using System.Text; | ||
|
||
namespace NServiceBus.Transport.RabbitMQ | ||
{ | ||
static class NameValidator | ||
{ | ||
public static void ThrowIfNameIsTooLong(string name) | ||
{ | ||
if (name.Length > 255) | ||
if (Encoding.UTF8.GetByteCount(name) > 255) | ||
{ | ||
throw new Exception($"{name} exceeds 255 characters which is maximal length for a queue or an exchange."); | ||
throw new Exception($"{name} exceeds 255 bytes which is maximal length for a queue or an exchange."); | ||
} | ||
} | ||
} | ||
} | ||
} |