From 41f259197d04c02fd6d3354cea4541b7f9dd0471 Mon Sep 17 00:00:00 2001 From: Patrick Strawderman Date: Sat, 2 Apr 2022 12:22:36 -0700 Subject: [PATCH] Replace usage of Stack with Deque / ArrayDeque Replace Stack with ArrayDeque in TypeInfo. --- src/main/java/graphql/schema/idl/TypeInfo.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/graphql/schema/idl/TypeInfo.java b/src/main/java/graphql/schema/idl/TypeInfo.java index fcc34b3fb4..fe12d49885 100644 --- a/src/main/java/graphql/schema/idl/TypeInfo.java +++ b/src/main/java/graphql/schema/idl/TypeInfo.java @@ -8,8 +8,9 @@ import graphql.language.TypeName; import graphql.schema.GraphQLType; +import java.util.ArrayDeque; +import java.util.Deque; import java.util.Objects; -import java.util.Stack; import static graphql.Assert.assertNotNull; import static graphql.schema.GraphQLList.list; @@ -27,7 +28,7 @@ public static TypeInfo typeInfo(Type type) { private final Type rawType; private final TypeName typeName; - private final Stack> decoration = new Stack<>(); + private final Deque> decoration = new ArrayDeque<>(); private TypeInfo(Type type) { this.rawType = assertNotNull(type, () -> "type must not be null"); @@ -79,8 +80,7 @@ public TypeInfo renameAs(String newName) { Type out = TypeName.newTypeName(newName).build(); - Stack> wrappingStack = new Stack<>(); - wrappingStack.addAll(this.decoration); + Deque> wrappingStack = new ArrayDeque<>(this.decoration); while (!wrappingStack.isEmpty()) { Class clazz = wrappingStack.pop(); if (clazz.equals(NonNullType.class)) { @@ -106,8 +106,7 @@ public TypeInfo renameAs(String newName) { public T decorate(GraphQLType objectType) { GraphQLType out = objectType; - Stack> wrappingStack = new Stack<>(); - wrappingStack.addAll(this.decoration); + Deque> wrappingStack = new ArrayDeque<>(this.decoration); while (!wrappingStack.isEmpty()) { Class clazz = wrappingStack.pop(); if (clazz.equals(NonNullType.class)) {