Skip to content

Commit

Permalink
addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
scottf committed Aug 30, 2021
1 parent f7a7803 commit d12ea32
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/NATS.Client/Internals/JsonUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal static List<string> OptionalStringList(JSONNode node, String field)
}

internal static byte[] AsByteArrayFromBase64(JSONNode node) {
return Validator.NullOrEmpty(node.Value) ? null : Convert.FromBase64String(node.Value);
return string.IsNullOrWhiteSpace(node.Value) ? null : Convert.FromBase64String(node.Value);
}

internal static DateTime AsDate(JSONNode node)
Expand Down
2 changes: 1 addition & 1 deletion src/NATS.Client/Internals/SimpleJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ internal partial class JSONString : JSONNode

public override JSONNodeType Tag { get { return JSONNodeType.String; } }
public override bool IsString { get { return true; } }
public override bool ShouldWrite { get { return !Validator.NullOrEmpty(m_Data); } }
public override bool ShouldWrite { get { return !string.IsNullOrWhiteSpace(m_Data); } }

public override Enumerator GetEnumerator() { return new Enumerator(); }

Expand Down
6 changes: 1 addition & 5 deletions src/NATS.Client/Internals/Validator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,7 @@ private static bool NotPrintableOrHasWildGtDollar(String s) {

internal static string EmptyAsNull(string s)
{
return NullOrEmpty(s) ? null : s;
}

internal static bool NullOrEmpty(String s) {
return s == null || s.Trim().Length == 0;
return string.IsNullOrWhiteSpace(s) ? null : s;
}

internal static bool ZeroOrLtMinus1(long l)
Expand Down
3 changes: 1 addition & 2 deletions src/NATS.Client/JetStream/ApiResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// limitations under the License.

using System.Text;
using NATS.Client.Internals;
using NATS.Client.Internals.SimpleJSON;

namespace NATS.Client.JetStream
Expand All @@ -35,7 +34,7 @@ internal ApiResponse(string json, bool throwOnError = false)
{
JsonNode = JSON.Parse(json);
Type = JsonNode[ApiConstants.Type].Value;
if (Validator.NullOrEmpty(Type))
if (string.IsNullOrWhiteSpace(Type))
{
Type = NoType;
}
Expand Down
2 changes: 1 addition & 1 deletion src/NATS.Client/JetStream/JetStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ Subscription CreateSubscription(string subject, string queueName,
else if (queueName == null) {
throw new ArgumentException($"Existing consumer [{durable}] is configured as a queue / deliver group.");
}
else if (!lookedUp.Equals(queueName)) {
else if (lookedUp != queueName) {
throw new ArgumentException(
$"Existing consumer deliver group {lookedUp} does not match requested queue / deliver group {queueName}.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/NATS.Client/JetStream/JetStreamManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private StreamInfo AddOrUpdateStream(StreamConfiguration config, string addUpdat
{
Validator.ValidateNotNull(config, nameof(config));

if (Validator.NullOrEmpty(config.Name)) {
if (string.IsNullOrWhiteSpace(config.Name)) {
throw new ArgumentException("Configuration must have a valid stream name");
}

Expand Down
2 changes: 1 addition & 1 deletion src/NATS.Client/JetStream/JsPrefixManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal static class JsPrefixManager
private static ConcurrentDictionary<string, string> JsPrefixes = new ConcurrentDictionary<string, string>();

internal static string AddPrefix(string prefix) {
if (Validator.NullOrEmpty(prefix) || prefix.Equals(JetStreamConstants.JsapiPrefix)) {
if (string.IsNullOrWhiteSpace(prefix) || prefix.Equals(JetStreamConstants.JsapiPrefix)) {
return JetStreamConstants.JsapiPrefix;
}

Expand Down
3 changes: 1 addition & 2 deletions src/NATS.Client/JetStream/ServerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

using System.Linq;
using System.Text;
using NATS.Client.Internals;
using NATS.Client.Internals.SimpleJSON;

namespace NATS.Client.JetStream
Expand Down Expand Up @@ -62,7 +61,7 @@ public ServerInfo(string json)
ClientIp = siNode[ApiConstants.ClientIp].Value;
Cluster = siNode[ApiConstants.Cluster].Value;
ConnectURLs = siNode[ApiConstants.ConnectUrls].Children
.Where(n => !Validator.NullOrEmpty(n.Value))
.Where(n => !string.IsNullOrWhiteSpace(n.Value))
.Select(n => n.Value)
.ToArray();
}
Expand Down

0 comments on commit d12ea32

Please sign in to comment.