Skip to content

Commit

Permalink
[FAB-7974] Fix zero-value checks for duration vars
Browse files Browse the repository at this point in the history
There is no reason for the zero-value checks to carry units.

Change-Id: I1830ce07f53161fe1886660efc5827239065e6f8
Signed-off-by: Kostas Christidis <kostas@christidis.io>
  • Loading branch information
kchristidis committed Jan 30, 2018
1 parent 3c9ab00 commit 35309fc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion core/peer/deliverevents.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (s *server) Deliver(srv peer.Deliver_DeliverServer) error {
// filtered block events
func NewDeliverEventsServer(mutualTLS bool, policyCheckerProvider PolicyCheckerProvider, supportManager deliver.SupportManager) peer.DeliverServer {
timeWindow := viper.GetDuration("peer.authentication.timewindow")
if timeWindow == 0*time.Minute {
if timeWindow == 0 {
defaultTimeWindow := 15 * time.Minute
logger.Warningf("`peer.authentication.timewindow` not set; defaulting to %s", defaultTimeWindow)
timeWindow = defaultTimeWindow
Expand Down
22 changes: 11 additions & 11 deletions orderer/common/localconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,52 +334,52 @@ func (c *TopLevel) completeInitialization(configDir string) {
logger.Infof("General.LocalMSPID unset, setting to %s", defaults.General.LocalMSPID)
c.General.LocalMSPID = defaults.General.LocalMSPID

case c.General.Authentication.TimeWindow == 0*time.Minute:
case c.General.Authentication.TimeWindow == 0:
logger.Infof("General.Authentication.TimeWindow unset, setting to %s", defaults.General.Authentication.TimeWindow)
c.General.Authentication.TimeWindow = defaults.General.Authentication.TimeWindow

case c.FileLedger.Prefix == "":
logger.Infof("FileLedger.Prefix unset, setting to %s", defaults.FileLedger.Prefix)
c.FileLedger.Prefix = defaults.FileLedger.Prefix

case c.Kafka.Retry.ShortInterval == 0*time.Minute:
case c.Kafka.Retry.ShortInterval == 0:
logger.Infof("Kafka.Retry.ShortInterval unset, setting to %v", defaults.Kafka.Retry.ShortInterval)
c.Kafka.Retry.ShortInterval = defaults.Kafka.Retry.ShortInterval
case c.Kafka.Retry.ShortTotal == 0*time.Minute:
case c.Kafka.Retry.ShortTotal == 0:
logger.Infof("Kafka.Retry.ShortTotal unset, setting to %v", defaults.Kafka.Retry.ShortTotal)
c.Kafka.Retry.ShortTotal = defaults.Kafka.Retry.ShortTotal
case c.Kafka.Retry.LongInterval == 0*time.Minute:
case c.Kafka.Retry.LongInterval == 0:
logger.Infof("Kafka.Retry.LongInterval unset, setting to %v", defaults.Kafka.Retry.LongInterval)
c.Kafka.Retry.LongInterval = defaults.Kafka.Retry.LongInterval
case c.Kafka.Retry.LongTotal == 0*time.Minute:
case c.Kafka.Retry.LongTotal == 0:
logger.Infof("Kafka.Retry.LongTotal unset, setting to %v", defaults.Kafka.Retry.LongTotal)
c.Kafka.Retry.LongTotal = defaults.Kafka.Retry.LongTotal

case c.Kafka.Retry.NetworkTimeouts.DialTimeout == 0*time.Second:
case c.Kafka.Retry.NetworkTimeouts.DialTimeout == 0:
logger.Infof("Kafka.Retry.NetworkTimeouts.DialTimeout unset, setting to %v", defaults.Kafka.Retry.NetworkTimeouts.DialTimeout)
c.Kafka.Retry.NetworkTimeouts.DialTimeout = defaults.Kafka.Retry.NetworkTimeouts.DialTimeout
case c.Kafka.Retry.NetworkTimeouts.ReadTimeout == 0*time.Second:
case c.Kafka.Retry.NetworkTimeouts.ReadTimeout == 0:
logger.Infof("Kafka.Retry.NetworkTimeouts.ReadTimeout unset, setting to %v", defaults.Kafka.Retry.NetworkTimeouts.ReadTimeout)
c.Kafka.Retry.NetworkTimeouts.ReadTimeout = defaults.Kafka.Retry.NetworkTimeouts.ReadTimeout
case c.Kafka.Retry.NetworkTimeouts.WriteTimeout == 0*time.Second:
case c.Kafka.Retry.NetworkTimeouts.WriteTimeout == 0:
logger.Infof("Kafka.Retry.NetworkTimeouts.WriteTimeout unset, setting to %v", defaults.Kafka.Retry.NetworkTimeouts.WriteTimeout)
c.Kafka.Retry.NetworkTimeouts.WriteTimeout = defaults.Kafka.Retry.NetworkTimeouts.WriteTimeout

case c.Kafka.Retry.Metadata.RetryBackoff == 0*time.Second:
case c.Kafka.Retry.Metadata.RetryBackoff == 0:
logger.Infof("Kafka.Retry.Metadata.RetryBackoff unset, setting to %v", defaults.Kafka.Retry.Metadata.RetryBackoff)
c.Kafka.Retry.Metadata.RetryBackoff = defaults.Kafka.Retry.Metadata.RetryBackoff
case c.Kafka.Retry.Metadata.RetryMax == 0:
logger.Infof("Kafka.Retry.Metadata.RetryMax unset, setting to %v", defaults.Kafka.Retry.Metadata.RetryMax)
c.Kafka.Retry.Metadata.RetryMax = defaults.Kafka.Retry.Metadata.RetryMax

case c.Kafka.Retry.Producer.RetryBackoff == 0*time.Second:
case c.Kafka.Retry.Producer.RetryBackoff == 0:
logger.Infof("Kafka.Retry.Producer.RetryBackoff unset, setting to %v", defaults.Kafka.Retry.Producer.RetryBackoff)
c.Kafka.Retry.Producer.RetryBackoff = defaults.Kafka.Retry.Producer.RetryBackoff
case c.Kafka.Retry.Producer.RetryMax == 0:
logger.Infof("Kafka.Retry.Producer.RetryMax unset, setting to %v", defaults.Kafka.Retry.Producer.RetryMax)
c.Kafka.Retry.Producer.RetryMax = defaults.Kafka.Retry.Producer.RetryMax

case c.Kafka.Retry.Consumer.RetryBackoff == 0*time.Second:
case c.Kafka.Retry.Consumer.RetryBackoff == 0:
logger.Infof("Kafka.Retry.Consumer.RetryBackoff unset, setting to %v", defaults.Kafka.Retry.Consumer.RetryBackoff)
c.Kafka.Retry.Consumer.RetryBackoff = defaults.Kafka.Retry.Consumer.RetryBackoff

Expand Down
2 changes: 1 addition & 1 deletion orderer/consensus/kafka/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (rp *retryProcess) try(interval, total time.Duration) (err error) {
// (which would result in panic). The path below is for those test cases
// when we cannot avoid the creation of a retriable process but we wish
// to terminate it right away.
if rp.shortPollingInterval == 0*time.Second {
if rp.shortPollingInterval == 0 {
return fmt.Errorf("illegal value")
}

Expand Down

0 comments on commit 35309fc

Please sign in to comment.