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
|
package xpath
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -55,6 +56,13 @@ func (d *protobufDocument) Init() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("creating file descriptor from proto failed: %v", err)
|
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 {
|
if err := protoregistry.GlobalFiles.RegisterFile(fileDesc); err != nil {
|
||||||
return fmt.Errorf("registering file descriptor %q failed: %v", fileDesc.Package(), err)
|
return fmt.Errorf("registering file descriptor %q failed: %v", fileDesc.Package(), err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue