Skip to content

Commit c3ef8a0

Browse files
neokyolyrashk
authored andcommitted
fixed concurrency problems when doing multiple queries in the same request (Enigmatis#49)
1 parent 812fd60 commit c3ef8a0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main/java/graphql/annotations/DefaultTypeFunction.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,11 @@ private class ObjectFunction implements TypeFunction {
230230
@Override
231231
public GraphQLType apply(Class<?> aClass, AnnotatedType annotatedType) {
232232
GraphQLName name = aClass.getAnnotation(GraphQLName.class);
233-
String typeName = name == null ? aClass.getSimpleName() : name.value();
234-
if (processing.containsKey(typeName)) {
235-
return processing.get(typeName);
233+
String typeName = name == null ? aClass.getName() : name.value();
234+
if (types.containsKey(typeName)) {
235+
return types.get(typeName);
236+
} else if (processing.containsKey(typeName)) {
237+
return processing.getOrDefault(typeName, new GraphQLTypeReference(typeName));
236238
} else {
237239
processing.put(typeName, new GraphQLTypeReference(typeName));
238240
GraphQLType type;
@@ -241,8 +243,8 @@ public GraphQLType apply(Class<?> aClass, AnnotatedType annotatedType) {
241243
} else {
242244
type = annotationsProcessor.getObject(aClass);
243245
}
244-
processing.remove(typeName);
245246
types.put(typeName, type);
247+
processing.remove(typeName);
246248
return type;
247249
}
248250
}

0 commit comments

Comments
 (0)