diff --git a/pubsub/topic.go b/pubsub/topic.go index 3c0f903473cb..cadb91a42f74 100644 --- a/pubsub/topic.go +++ b/pubsub/topic.go @@ -19,7 +19,6 @@ import ( "errors" "fmt" "log" - "math" "runtime" "strings" "sync" @@ -53,6 +52,13 @@ const ( MaxPublishRequestBytes = 1e7 ) +const ( + // TODO: math.MaxInt was added in Go 1.17. We should use that once 1.17 + // becomes the minimum supported version of Go. + intSize = 32 << (^uint(0) >> 63) + maxInt = 1<<(intSize-1) - 1 +) + // ErrOversizedMessage indicates that a message's size exceeds MaxPublishRequestBytes. var ErrOversizedMessage = bundler.ErrOversizedItem @@ -639,7 +645,7 @@ func (t *Topic) initBundler() { // This is because there's no way to set "unlimited" for BufferedByteLimit, // and simply setting it to MaxOutstandingBytes occasionally leads to issues where // BufferedByteLimit is reached even though there are resources available. - t.PublishSettings.BufferedByteLimit = math.MaxInt64 + t.PublishSettings.BufferedByteLimit = maxInt } if t.PublishSettings.FlowControlSettings.MaxOutstandingMessages > 0 { fcs.MaxOutstandingMessages = t.PublishSettings.FlowControlSettings.MaxOutstandingMessages