Skip to content

Commit

Permalink
Check string utf8 byte size instead of string length
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonsmits authored and bording committed Jul 8, 2020
1 parent c0d1471 commit 7a3f2e9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/NServiceBus.Transport.RabbitMQ/Routing/NameValidator.cs
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.");
}
}
}
}
}

0 comments on commit 7a3f2e9

Please sign in to comment.