@@ -92,7 +92,7 @@ public GraphQLServlet(List<GraphQLOperationListener> operationListeners, List<Gr
9292 this .fileUpload = new ServletFileUpload (fileItemFactory != null ? fileItemFactory : new DiskFileItemFactory ());
9393
9494 this .getHandler = (request , response ) -> {
95- GraphQLContext context = createContext (Optional .of (request ), Optional .of (response ));
95+ final GraphQLContext context = createContext (Optional .of (request ), Optional .of (response ));
9696 String path = request .getPathInfo ();
9797 if (path == null ) {
9898 path = request .getServletPath ();
@@ -101,7 +101,7 @@ public GraphQLServlet(List<GraphQLOperationListener> operationListeners, List<Gr
101101 query (CharStreams .toString (new InputStreamReader (GraphQLServlet .class .getResourceAsStream ("introspectionQuery" ))), null , new HashMap <>(), getSchema (), request , response , context );
102102 } else {
103103 if (request .getParameter ("query" ) != null ) {
104- Map <String , Object > variables = new HashMap <>();
104+ final Map <String , Object > variables = new HashMap <>();
105105 if (request .getParameter ("variables" ) != null ) {
106106 variables .putAll (mapper .readValue (request .getParameter ("variables" ), new TypeReference <Map <String , Object >>() { }));
107107 }
@@ -118,43 +118,43 @@ public GraphQLServlet(List<GraphQLOperationListener> operationListeners, List<Gr
118118 };
119119
120120 this .postHandler = (request , response ) -> {
121- GraphQLContext context = createContext (Optional .of (request ), Optional .of (response ));
121+ final GraphQLContext context = createContext (Optional .of (request ), Optional .of (response ));
122122 GraphQLRequest graphQLRequest = null ;
123123
124124 try {
125125 InputStream inputStream = null ;
126126
127127 if (ServletFileUpload .isMultipartContent (request )) {
128- Map <String , List <FileItem >> fileItems = fileUpload .parseParameterMap (request );
128+ final Map <String , List <FileItem >> fileItems = fileUpload .parseParameterMap (request );
129129
130130 if (fileItems .containsKey ("graphql" )) {
131- Optional <FileItem > graphqlItem = getFileItem (fileItems , "graphql" );
132- if (graphqlItem .isPresent ()) {
131+ final Optional <FileItem > graphqlItem = getFileItem (fileItems , "graphql" );
132+ if (graphqlItem .isPresent ()) {
133133 inputStream = graphqlItem .get ().getInputStream ();
134134 }
135135
136- } else if (fileItems .containsKey ("query" )) {
137- Optional <FileItem > queryItem = getFileItem (fileItems , "query" );
138- if (queryItem .isPresent ()) {
136+ } else if (fileItems .containsKey ("query" )) {
137+ final Optional <FileItem > queryItem = getFileItem (fileItems , "query" );
138+ if (queryItem .isPresent ()) {
139139 graphQLRequest = new GraphQLRequest ();
140140 graphQLRequest .setQuery (new String (queryItem .get ().get ()));
141141
142- Optional <FileItem > operationNameItem = getFileItem (fileItems , "operationName" );
143- if (operationNameItem .isPresent ()) {
142+ final Optional <FileItem > operationNameItem = getFileItem (fileItems , "operationName" );
143+ if (operationNameItem .isPresent ()) {
144144 graphQLRequest .setOperationName (new String (operationNameItem .get ().get ()).trim ());
145145 }
146146
147- Optional <FileItem > variablesItem = getFileItem (fileItems , "variables" );
148- if (variablesItem .isPresent ()) {
147+ final Optional <FileItem > variablesItem = getFileItem (fileItems , "variables" );
148+ if (variablesItem .isPresent ()) {
149149 String variables = new String (variablesItem .get ().get ());
150- if (!variables .isEmpty ()) {
150+ if (!variables .isEmpty ()) {
151151 graphQLRequest .setVariables ((Map <String , Object >) mapper .readValue (variables , Map .class ));
152152 }
153153 }
154154 }
155155 }
156156
157- if (inputStream == null && graphQLRequest == null ) {
157+ if (inputStream == null && graphQLRequest == null ) {
158158 response .setStatus (STATUS_BAD_REQUEST );
159159 log .info ("Bad POST multipart request: no part named \" graphql\" or \" query\" " );
160160 return ;
@@ -167,7 +167,7 @@ public GraphQLServlet(List<GraphQLOperationListener> operationListeners, List<Gr
167167 inputStream = request .getInputStream ();
168168 }
169169
170- if (graphQLRequest == null ) {
170+ if (graphQLRequest == null ) {
171171 graphQLRequest = mapper .readValue (inputStream , GraphQLRequest .class );
172172 }
173173
@@ -215,7 +215,7 @@ public String[] getMutations() {
215215 @ Override @ SneakyThrows
216216 public String executeQuery (String query ) {
217217 try {
218- ExecutionResult result = new GraphQL (getSchema ()).execute (query , createContext (Optional .empty (), Optional .empty ()), new HashMap <>());
218+ final ExecutionResult result = new GraphQL (getSchema ()).execute (query , createContext (Optional .empty (), Optional .empty ()), new HashMap <>());
219219 return mapper .writeValueAsString (createResultFromDataAndErrors (result .getData (), result .getErrors ()));
220220 } catch (Exception e ) {
221221 return e .getMessage ();
@@ -268,11 +268,11 @@ public Void run() {
268268 } else {
269269 runListeners (operationListeners , l -> runListener (l , it -> it .beforeGraphQLOperation (context , operationName , query , variables )));
270270
271- ExecutionResult executionResult = new GraphQL (schema , getExecutionStrategy ()).execute (query , operationName , context , transformVariables (schema , query , variables ));
272- List <GraphQLError > errors = executionResult .getErrors ();
273- Object data = executionResult .getData ();
271+ final ExecutionResult executionResult = new GraphQL (schema , getExecutionStrategy ()).execute (query , operationName , context , transformVariables (schema , query , variables ));
272+ final List <GraphQLError > errors = executionResult .getErrors ();
273+ final Object data = executionResult .getData ();
274274
275- String response = mapper .writeValueAsString (createResultFromDataAndErrors (data , errors ));
275+ final String response = mapper .writeValueAsString (createResultFromDataAndErrors (data , errors ));
276276
277277 resp .setContentType (APPLICATION_JSON_UTF8 );
278278 resp .setStatus (STATUS_OK );
@@ -288,12 +288,12 @@ public Void run() {
288288
289289 private Map <String , Object > createResultFromDataAndErrors (Object data , List <GraphQLError > errors ) {
290290
291- Map <String , Object > result = new HashMap <>();
291+ final Map <String , Object > result = new HashMap <>();
292292 result .put ("data" , data );
293293
294294 if (errorsPresent (errors )) {
295- List <GraphQLError > clientErrors = filterGraphQLErrors (errors );
296- if (clientErrors .size () < errors .size ()) {
295+ final List <GraphQLError > clientErrors = filterGraphQLErrors (errors );
296+ if (clientErrors .size () < errors .size ()) {
297297 // Some errors were filtered out to hide implementation - put a generic error in place.
298298 clientErrors .add (new GenericGraphQLError ("Internal Server Error(s) while executing query" ));
299299 }
@@ -314,7 +314,7 @@ protected List<GraphQLError> filterGraphQLErrors(List<GraphQLError> errors) {
314314 }
315315
316316 private <T > void runListeners (List <T > listeners , Consumer <? super T > action ) {
317- if (listeners != null ) {
317+ if (listeners != null ) {
318318 listeners .forEach (l -> runListener (l , action ));
319319 }
320320 }
@@ -333,7 +333,7 @@ private <T> void runListener(T listener, Consumer<? super T> action) {
333333 protected static class VariablesDeserializer extends JsonDeserializer <Map <String , Object >> {
334334 @ Override
335335 public Map <String , Object > deserialize (JsonParser p , DeserializationContext ctxt ) throws IOException {
336- Object o = p .readValueAs (Object .class );
336+ final Object o = p .readValueAs (Object .class );
337337 if (o instanceof Map ) {
338338 return (Map <String , Object >) o ;
339339 } else if (o instanceof String ) {
0 commit comments