Skip to content

Commit 17a4dbe

Browse files
committed
[PDR-13372][fix(panic)]修复获取文件真实路径报空指针异常问题
1 parent d60f1b5 commit 17a4dbe

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
@@ -650,6 +650,11 @@ func (r *Reader) checkExpiredFiles() {
650650
}
651651

652652
func (r *Reader) statLogPath() {
653+
defer func() {
654+
if rec := recover(); rec != nil {
655+
log.Errorf("Reader %q was panicked and recovered from %v\nstack: %s", r.Name(), rec, debug.Stack())
656+
}
657+
}()
653658
//达到最大打开文件数,不再追踪
654659
if len(r.fileReaders) >= r.maxOpenFiles {
655660
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)