Skip to content

Commit f56acc4

Browse files
author
liukai2012
authored
Merge pull request #1152 from PapaPiya/fix_getrealpath
[PDR-13372][fix(panic)]修复获取文件真实路径报空指针异常问题
2 parents 39d089a + 17a4dbe commit f56acc4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

reader/tailx/tailx.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,11 @@ func (r *Reader) checkExpiredFiles() {
696696
}
697697

698698
func (r *Reader) statLogPath() {
699+
defer func() {
700+
if rec := recover(); rec != nil {
701+
log.Errorf("Reader %q was panicked and recovered from %v\nstack: %s", r.Name(), rec, debug.Stack())
702+
}
703+
}()
699704
//达到最大打开文件数,不再追踪
700705
if len(r.fileReaders) >= r.maxOpenFiles {
701706
if !IsSelfRunner(r.meta.RunnerName) {

utils/models/utils.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,9 @@ func GetRealPath(path string) (newPath string, fi os.FileInfo, err error) {
703703
}
704704
log.Infof("%s is symbol link to %v", path, newPath)
705705
fi, err = os.Lstat(newPath)
706+
if err != nil {
707+
return
708+
}
706709
}
707710
newPath, err = filepath.Abs(newPath)
708711
if err != nil {

0 commit comments

Comments
 (0)