You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2020/11/05 09:35:06 UTC
[sling-org-apache-sling-graphql-core] branch master updated:
SLING-9877 - cleanup
This is an automated email from the ASF dual-hosted git repository.
bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-graphql-core.git
The following commit(s) were added to refs/heads/master by this push:
new 220eb1b SLING-9877 - cleanup
220eb1b is described below
commit 220eb1b4368157142a4c0e82329dbbaf96f0be34
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Nov 5 10:28:26 2020 +0100
SLING-9877 - cleanup
---
.../apache/sling/graphql/core/util/SlingGraphQLErrorHelper.java | 7 +++++--
.../sling/graphql/core/util/SlingGraphQLErrorHelperTest.java | 5 -----
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/sling/graphql/core/util/SlingGraphQLErrorHelper.java b/src/main/java/org/apache/sling/graphql/core/util/SlingGraphQLErrorHelper.java
index 6d251a3..4231128 100644
--- a/src/main/java/org/apache/sling/graphql/core/util/SlingGraphQLErrorHelper.java
+++ b/src/main/java/org/apache/sling/graphql/core/util/SlingGraphQLErrorHelper.java
@@ -33,6 +33,9 @@ public class SlingGraphQLErrorHelper {
public static final String GRAPHQL_ERROR_CAUSE_STACKTRACE = "stacktrace";
public static final String GRAPHQL_ERROR_ERRORS = "errors";
+ /** Keep only this many level of exception stack traces */
+ public static int MAX_STACK_TRACE_DEPTH = 10;
+
private SlingGraphQLErrorHelper(){
}
@@ -53,8 +56,8 @@ public class SlingGraphQLErrorHelper {
extensionsMap.put(GRAPHQL_ERROR_CAUSE, e.getCause().toString());
final List<String> stacktrace = new ArrayList<>();
- //keep top 10 (max) stacktrace entries
- for (int i=0; i<e.getCause().getStackTrace().length && i<10; i++) {
+ //keep top MAX_STACK_TRACE_DEPTH stacktrace entries
+ for (int i=0; i<e.getCause().getStackTrace().length && i<MAX_STACK_TRACE_DEPTH; i++) {
stacktrace.add(e.getCause().getStackTrace()[i].toString());
}
extensionsMap.put(GRAPHQL_ERROR_CAUSE_STACKTRACE, stacktrace);
diff --git a/src/test/java/org/apache/sling/graphql/core/util/SlingGraphQLErrorHelperTest.java b/src/test/java/org/apache/sling/graphql/core/util/SlingGraphQLErrorHelperTest.java
index 523caed..9737a18 100644
--- a/src/test/java/org/apache/sling/graphql/core/util/SlingGraphQLErrorHelperTest.java
+++ b/src/test/java/org/apache/sling/graphql/core/util/SlingGraphQLErrorHelperTest.java
@@ -18,9 +18,6 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package org.apache.sling.graphql.core.util;
-import graphql.GraphqlErrorHelper;
-import org.apache.sling.graphql.core.engine.ResourceQueryTestBase;
-import org.apache.sling.graphql.core.mocks.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
@@ -28,8 +25,6 @@ import org.mockito.junit.MockitoJUnitRunner;
import java.security.InvalidParameterException;
import java.util.*;
-import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
-import static org.hamcrest.Matchers.is;
import static org.junit.Assert.*;
@RunWith(MockitoJUnitRunner.class)