fix: Handle duplicate registration of protocol-buffer files gracefully. (#10188)
This commit is contained in:
parent
1b9572085b
commit
aa642a4046
|
|
@ -1,6 +1,7 @@
|
|||
package xpath
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
|
@ -55,6 +56,13 @@ func (d *protobufDocument) Init() error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("creating file descriptor from proto failed: %v", err)
|
||||
}
|
||||
if _, err := protoregistry.GlobalFiles.FindFileByPath(fileDesc.Path()); !errors.Is(err, protoregistry.NotFound) {
|
||||
if err != nil {
|
||||
return fmt.Errorf("searching for file %q in registry failed: %v", fileDesc.Path(), err)
|
||||
}
|
||||
d.Log.Warnf("Protocol buffer with path %q already registered. Skipping...", fileDesc.Path())
|
||||
continue
|
||||
}
|
||||
if err := protoregistry.GlobalFiles.RegisterFile(fileDesc); err != nil {
|
||||
return fmt.Errorf("registering file descriptor %q failed: %v", fileDesc.Package(), err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue