diff --git a/.github/tag-release.sh b/.github/tag-release.sh index 0c567951..d80c1699 100755 --- a/.github/tag-release.sh +++ b/.github/tag-release.sh @@ -51,4 +51,4 @@ echo "Deploying release to Maven Central" removeSnapshots commitRelease bumpVersion -git push --follow-tags +git push --follow-tags \ No newline at end of file diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 5be6997d..3882c278 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -17,7 +17,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] - java: [ 8, 11, 15 ] + java: [ 11 ] needs: validation runs-on: ${{ matrix.os }} steps: diff --git a/README.md b/README.md index 8cd4efe3..1967bd18 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# GraphQL Java Servlet +# GraphQL Java Servlet 14 [![Maven Central](https://img.shields.io/maven-central/v/com.graphql-java-kickstart/graphql-java-servlet.svg)](https://maven-badges.herokuapp.com/maven-central/com.graphql-java-kickstart/graphql-java-servlet) [![Build Status](https://github.com/graphql-java-kickstart/graphql-java-servlet/workflows/Publish%20snapshot/badge.svg)](https://github.com/graphql-java-kickstart/graphql-java-servlet/actions?query=workflow%3A%22Publish+snapshot%22) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=graphql-java-kickstart_graphql-java-servlet&metric=alert_status)](https://sonarcloud.io/dashboard?id=graphql-java-kickstart_graphql-java-servlet) @@ -19,10 +19,17 @@ This project wraps the Java implementation of GraphQL provided by [GraphQL Java] See [GraphQL Java documentation](https://www.graphql-java.com/documentation/latest/) for more in depth details regarding GraphQL Java itself. -We try to stay up to date with GraphQL Java as much as possible. The current version supports - **GraphQL Java 17.3**. - -This project requires at least Java 8. +We try to stay up to date with GraphQL Java as much as possible maintaining the retro-compatibility +with Springframework 5. + +The `14.*` version must be used if your project is based on Spring version <= `5`, +or it is using javax-servlet-api dependency and cannot be upgraded to jakarta. + +It also supports legacy projects that can compile with older JDK versions: the oldest supported one +is the `11`. + + +See [gradle.properties](gradle.properties) to see currently supported versions. ## Installation and getting started diff --git a/build.gradle b/build.gradle index 0bd99646..ca0f6f45 100644 --- a/build.gradle +++ b/build.gradle @@ -27,10 +27,10 @@ buildscript { } plugins { - id "biz.aQute.bnd.builder" version "6.3.1" apply false - id "org.sonarqube" version "3.4.0.2513" + id "biz.aQute.bnd.builder" version "6.4.0" apply false + id "org.sonarqube" version "4.0.0.2929" id "jacoco" - id "io.github.gradle-nexus.publish-plugin" version '1.1.0' + id "io.github.gradle-nexus.publish-plugin" version '1.3.0' } sonarqube { diff --git a/examples/osgi/apache-karaf-feature/pom.xml b/examples/osgi/apache-karaf-feature/pom.xml index 66e9eec4..9b52910b 100644 --- a/examples/osgi/apache-karaf-feature/pom.xml +++ b/examples/osgi/apache-karaf-feature/pom.xml @@ -112,7 +112,7 @@ - 2.12.6.1 + 2.13.4.2 diff --git a/examples/osgi/pom.xml b/examples/osgi/pom.xml index c51bd1e0..a0daab35 100644 --- a/examples/osgi/pom.xml +++ b/examples/osgi/pom.xml @@ -17,8 +17,8 @@ 11.0.0-SNAPSHOT 16.1 4.2.10 - 1.8 - 1.8 +u 11 + 11 10.1.0 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e5832..c1962a79 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8fad3f5a..8707e8b5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index a69d9cb6..aeb74cbb 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -143,12 +140,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in diff --git a/gradlew.bat b/gradlew.bat index 53a6b238..6689b85b 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% diff --git a/graphql-java-kickstart/build.gradle b/graphql-java-kickstart/build.gradle index b336ca2f..b6639991 100644 --- a/graphql-java-kickstart/build.gradle +++ b/graphql-java-kickstart/build.gradle @@ -14,6 +14,6 @@ dependencies { // JSON api "com.fasterxml.jackson.core:jackson-core:$LIB_JACKSON_VER" api "com.fasterxml.jackson.core:jackson-annotations:$LIB_JACKSON_VER" - api "com.fasterxml.jackson.core:jackson-databind:2.13.3" + api "com.fasterxml.jackson.core:jackson-databind:2.15.0" api "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:$LIB_JACKSON_VER" } diff --git a/graphql-java-kickstart/src/main/java/graphql/kickstart/execution/GraphQLQueryInvoker.java b/graphql-java-kickstart/src/main/java/graphql/kickstart/execution/GraphQLQueryInvoker.java index 19370561..a8749488 100644 --- a/graphql-java-kickstart/src/main/java/graphql/kickstart/execution/GraphQLQueryInvoker.java +++ b/graphql-java-kickstart/src/main/java/graphql/kickstart/execution/GraphQLQueryInvoker.java @@ -50,7 +50,8 @@ public static class Builder { private Supplier getExecutionStrategyProvider = DefaultExecutionStrategyProvider::new; - private Supplier getInstrumentation = () -> SimplePerformantInstrumentation.INSTANCE; + private Supplier getInstrumentation = + () -> SimplePerformantInstrumentation.INSTANCE; private Supplier getPreparsedDocumentProvider = () -> NoOpPreparsedDocumentProvider.INSTANCE; private Supplier diff --git a/graphql-java-kickstart/src/main/java/graphql/kickstart/execution/config/GraphQLBuilder.java b/graphql-java-kickstart/src/main/java/graphql/kickstart/execution/config/GraphQLBuilder.java index 7f5c1dcd..aa43deaa 100644 --- a/graphql-java-kickstart/src/main/java/graphql/kickstart/execution/config/GraphQLBuilder.java +++ b/graphql-java-kickstart/src/main/java/graphql/kickstart/execution/config/GraphQLBuilder.java @@ -20,7 +20,8 @@ public class GraphQLBuilder { () -> NoOpPreparsedDocumentProvider.INSTANCE; @Getter - private Supplier instrumentationSupplier = () -> SimplePerformantInstrumentation.INSTANCE; + private Supplier instrumentationSupplier = + () -> SimplePerformantInstrumentation.INSTANCE; private Supplier graphQLBuilderConfigurerSupplier = () -> builder -> {}; diff --git a/graphql-java-kickstart/src/main/java/graphql/kickstart/execution/instrumentation/ConfigurableDispatchInstrumentation.java b/graphql-java-kickstart/src/main/java/graphql/kickstart/execution/instrumentation/ConfigurableDispatchInstrumentation.java index 23565b2e..76c891af 100644 --- a/graphql-java-kickstart/src/main/java/graphql/kickstart/execution/instrumentation/ConfigurableDispatchInstrumentation.java +++ b/graphql-java-kickstart/src/main/java/graphql/kickstart/execution/instrumentation/ConfigurableDispatchInstrumentation.java @@ -65,10 +65,12 @@ public InstrumentationState createState(InstrumentationCreateStateParameters par } @Override - public DataFetcher instrumentDataFetcher(DataFetcher dataFetcher, - InstrumentationFieldFetchParameters parameters, InstrumentationState instrumentationState) { - DataLoaderDispatcherInstrumentationState state = InstrumentationState.ofState( - instrumentationState); + public DataFetcher instrumentDataFetcher( + DataFetcher dataFetcher, + InstrumentationFieldFetchParameters parameters, + InstrumentationState instrumentationState) { + DataLoaderDispatcherInstrumentationState state = + InstrumentationState.ofState(instrumentationState); if (state.isAggressivelyBatching()) { return dataFetcher; } @@ -92,8 +94,8 @@ public InstrumentationContext beginExecuteOperation( InstrumentationExecuteOperationParameters parameters, InstrumentationState instrumentationState) { if (!isDataLoaderCompatible(parameters.getExecutionContext())) { - DataLoaderDispatcherInstrumentationState state = InstrumentationState.ofState( - instrumentationState); + DataLoaderDispatcherInstrumentationState state = + InstrumentationState.ofState(instrumentationState); state.setAggressivelyBatching(false); } return SimpleInstrumentationContext.noOp(); @@ -117,8 +119,8 @@ private boolean isDataLoaderCompatible(ExecutionContext executionContext) { public ExecutionStrategyInstrumentationContext beginExecutionStrategy( InstrumentationExecutionStrategyParameters parameters, InstrumentationState instrumentationState) { - DataLoaderDispatcherInstrumentationState state = InstrumentationState.ofState( - instrumentationState); + DataLoaderDispatcherInstrumentationState state = + InstrumentationState.ofState(instrumentationState); // // if there are no data loaders, there is nothing to do // @@ -141,8 +143,8 @@ public void onCompleted(ExecutionResult result, Throwable t) { @Override public InstrumentationContext beginFieldFetch( InstrumentationFieldFetchParameters parameters, InstrumentationState instrumentationState) { - DataLoaderDispatcherInstrumentationState state = InstrumentationState.ofState( - instrumentationState); + DataLoaderDispatcherInstrumentationState state = + InstrumentationState.ofState(instrumentationState); // // if there are no data loaders, there is nothing to do // @@ -154,10 +156,11 @@ public InstrumentationContext beginFieldFetch( @Override public CompletableFuture instrumentExecutionResult( - ExecutionResult executionResult, InstrumentationExecutionParameters parameters, + ExecutionResult executionResult, + InstrumentationExecutionParameters parameters, InstrumentationState instrumentationState) { - DataLoaderDispatcherInstrumentationState state = InstrumentationState.ofState( - instrumentationState); + DataLoaderDispatcherInstrumentationState state = + InstrumentationState.ofState(instrumentationState); state.getApproach().removeTracking(parameters.getExecutionInput().getExecutionId()); if (!options.isIncludeStatistics()) { return CompletableFuture.completedFuture(executionResult); diff --git a/graphql-java-servlet/build.gradle b/graphql-java-servlet/build.gradle index 5600274f..2e3df0b1 100644 --- a/graphql-java-servlet/build.gradle +++ b/graphql-java-servlet/build.gradle @@ -18,6 +18,7 @@ dependencies { // Servlet compileOnly 'javax.servlet:javax.servlet-api:4.0.1' compileOnly 'javax.websocket:javax.websocket-api:1.1' + compileOnly 'javax.websocket:javax.websocket-client-api:1.1' implementation "org.slf4j:slf4j-api:$LIB_SLF4J_VER" // OSGi @@ -36,9 +37,10 @@ dependencies { testRuntimeOnly "cglib:cglib-nodep:3.3.0" testRuntimeOnly "org.objenesis:objenesis:3.3" testImplementation "org.slf4j:slf4j-simple:$LIB_SLF4J_VER" - testImplementation 'org.springframework:spring-test:5.3.22' - testRuntimeOnly 'org.springframework:spring-web:5.3.22' + testImplementation 'org.springframework:spring-test:5.3.25' + testRuntimeOnly 'org.springframework:spring-web:5.3.25' testImplementation 'com.google.guava:guava:31.1-jre' testImplementation 'javax.servlet:javax.servlet-api:4.0.1' testImplementation 'javax.websocket:javax.websocket-api:1.1' + testImplementation 'javax.websocket:javax.websocket-client-api:1.1' } diff --git a/graphql-java-servlet/src/main/java/graphql/kickstart/servlet/HttpRequestInvokerImpl.java b/graphql-java-servlet/src/main/java/graphql/kickstart/servlet/HttpRequestInvokerImpl.java index 8f24c3ca..ccc10209 100644 --- a/graphql-java-servlet/src/main/java/graphql/kickstart/servlet/HttpRequestInvokerImpl.java +++ b/graphql-java-servlet/src/main/java/graphql/kickstart/servlet/HttpRequestInvokerImpl.java @@ -116,6 +116,9 @@ private void handle( response.setStatus(STATUS_INTERNAL_SERVER_ERROR); log.error("Cannot handle http request", e); listenerHandler.onError(e); + if (e instanceof InterruptedException) { + Thread.currentThread().interrupt(); + } } } diff --git a/graphql-java-servlet/src/test/groovy/graphql/kickstart/servlet/AbstractGraphQLHttpServletSpec.groovy b/graphql-java-servlet/src/test/groovy/graphql/kickstart/servlet/AbstractGraphQLHttpServletSpec.groovy index a7f9e5da..dde7cb46 100644 --- a/graphql-java-servlet/src/test/groovy/graphql/kickstart/servlet/AbstractGraphQLHttpServletSpec.groovy +++ b/graphql-java-servlet/src/test/groovy/graphql/kickstart/servlet/AbstractGraphQLHttpServletSpec.groovy @@ -1120,7 +1120,7 @@ b throw new TestException() }.build()).build() servlet = GraphQLHttpServlet.with(configuration) - servlet.init(null) + servlet.init() request.setPathInfo('/schema.json') diff --git a/graphql-java-servlet/src/test/groovy/graphql/kickstart/servlet/TestUtils.groovy b/graphql-java-servlet/src/test/groovy/graphql/kickstart/servlet/TestUtils.groovy index 797f5048..684b2cc2 100644 --- a/graphql-java-servlet/src/test/groovy/graphql/kickstart/servlet/TestUtils.groovy +++ b/graphql-java-servlet/src/test/groovy/graphql/kickstart/servlet/TestUtils.groovy @@ -62,7 +62,7 @@ class TestUtils { .with(contextBuilder) .with(executor()) .build()) - servlet.init(null) + servlet.init() return servlet } @@ -86,7 +86,7 @@ class TestUtils { listeners ) ) - servlet.init(null) + servlet.init() return servlet }