mosn / pkg

Common packages used by other repos.
Apache License 2.0
26 stars 28 forks source link

bugfix: global roller maxtime update from default value to 0 will panic #76

Closed dengqian closed 1 year ago

dengqian commented 1 year ago
        logger, _ := GetOrCreateLogger("/tmp/testlog.txt", nil)
    time.Sleep(time.Second)
    InitGlobalRoller("age=7 size=500 compress=on")

Codes will panic at:

case <-l.rollerUpdate:
            if !timer.Stop() {
                select {
                case <-timer.C:
                default:
                }
            }

            now := time.Now()
            interval = l.calculateInterval(now)

...
_, localOffset := now.Zone()
    return time.Duration(l.roller.MaxTime-(now.Unix()+int64(localOffset))%l.roller.MaxTime) * time.Second
codecov-commenter commented 1 year ago

Codecov Report

Base: 50.14% // Head: 50.11% // Decreases project coverage by -0.03% :warning:

Coverage data is based on head (9f9e38c) compared to base (9c74706). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #76 +/- ## ========================================== - Coverage 50.14% 50.11% -0.04% ========================================== Files 56 56 Lines 3013 3017 +4 ========================================== + Hits 1511 1512 +1 - Misses 1405 1407 +2 - Partials 97 98 +1 ``` | [Impacted Files](https://codecov.io/gh/mosn/pkg/pull/76?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mosn) | Coverage Δ | | |---|---|---| | [log/roller.go](https://codecov.io/gh/mosn/pkg/pull/76?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mosn#diff-bG9nL3JvbGxlci5nbw==) | `91.58% <ø> (-0.08%)` | :arrow_down: | | [log/logger.go](https://codecov.io/gh/mosn/pkg/pull/76?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mosn#diff-bG9nL2xvZ2dlci5nbw==) | `53.06% <100.00%> (+0.97%)` | :arrow_up: | | [buffer/iobuffer.go](https://codecov.io/gh/mosn/pkg/pull/76?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mosn#diff-YnVmZmVyL2lvYnVmZmVyLmdv) | `77.62% <0.00%> (-1.05%)` | :arrow_down: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mosn). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mosn)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.