Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove cache for thrift reflection to avoid race #229

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 8 additions & 60 deletions thrift_reflection/descriptor-extend.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ func (s *ServiceDescriptor) GetParent() *ServiceDescriptor {
}

func (s *ServiceDescriptor) GetAllMethods() []*MethodDescriptor {

allMethods := []*MethodDescriptor{}

svc := s
Expand All @@ -271,7 +270,6 @@ func (s *ServiceDescriptor) GetAllMethods() []*MethodDescriptor {
}

func (s *ServiceDescriptor) GetMethodByNameFromAll(name string) *MethodDescriptor {

for _, m := range s.GetAllMethods() {
if m.GetName() == name {
return m
Expand Down Expand Up @@ -338,67 +336,27 @@ func (td *TypeDescriptor) GetStructDescriptor() (*StructDescriptor, error) {
}

func (td *TypeDescriptor) IsException() bool {
if td.Extra == nil {
td.Extra = map[string]string{}
}
cacheType, ok := td.Extra["type"]
if ok {
return cacheType == "exception"
}
sd, err := td.GetExceptionDescriptor()
isStruct := err == nil && sd != nil
if isStruct {
td.Extra["type"] = "exception"
}
return isStruct
isException := err == nil && sd != nil
return isException
}

func (td *TypeDescriptor) IsUnion() bool {
if td.Extra == nil {
td.Extra = map[string]string{}
}
cacheType, ok := td.Extra["type"]
if ok {
return cacheType == "union"
}
sd, err := td.GetUnionDescriptor()
isStruct := err == nil && sd != nil
if isStruct {
td.Extra["type"] = "union"
}
return isStruct
isUnion := err == nil && sd != nil
return isUnion
}

func (td *TypeDescriptor) IsStruct() bool {
if td.Extra == nil {
td.Extra = map[string]string{}
}
cacheType, ok := td.Extra["type"]
if ok {
return cacheType == "struct"
}
sd, err := td.GetStructDescriptor()
isStruct := err == nil && sd != nil
if isStruct {
td.Extra["type"] = "struct"
}
return isStruct
}

func (td *TypeDescriptor) IsEnum() bool {
if td.Extra == nil {
td.Extra = map[string]string{}
}
cacheType, ok := td.Extra["type"]
if ok {
return cacheType == "enum"
}
sd, err := td.GetEnumDescriptor()
isStruct := err == nil && sd != nil
if isStruct {
td.Extra["type"] = "enum"
}
return isStruct
isEnum := err == nil && sd != nil
return isEnum
}

func (td *TypeDescriptor) GetEnumDescriptor() (*EnumDescriptor, error) {
Expand All @@ -417,19 +375,9 @@ func (td *TypeDescriptor) GetEnumDescriptor() (*EnumDescriptor, error) {
}

func (td *TypeDescriptor) IsTypedef() bool {
if td.Extra == nil {
td.Extra = map[string]string{}
}
cacheType, ok := td.Extra["type"]
if ok {
return cacheType == "typedef"
}
sd, err := td.GetTypedefDescriptor()
isStruct := err == nil && sd != nil
if isStruct {
td.Extra["type"] = "typedef"
}
return isStruct
isTypedef := err == nil && sd != nil
return isTypedef
}

func (td *TypeDescriptor) GetTypedefDescriptor() (*TypedefDescriptor, error) {
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

package version

const ThriftgoVersion = "0.3.16"
const ThriftgoVersion = "0.3.17"
Loading