Skip to content

Commit efe661a

Browse files
committed
Merge branch 'master' into schema-block-check
2 parents 5287835 + 4c66935 commit efe661a

21 files changed

Lines changed: 463 additions & 94 deletions

.github/workflows/master.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v1
1717
- uses: gradle/wrapper-validation-action@v1
18-
- name: Set up JDK 11
18+
- name: Set up JDK 1.8
1919
uses: actions/setup-java@v1
2020
with:
21-
java-version: '11.0.17'
21+
java-version: '8.0.282'
2222
- name: build test and publish
2323
run: ./gradlew assemble && ./gradlew check --info && ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -x check --info --stacktrace

.github/workflows/pull_request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v1
1818
- uses: gradle/wrapper-validation-action@v1
19-
- name: Set up JDK 11
19+
- name: Set up JDK 1.8
2020
uses: actions/setup-java@v1
2121
with:
22-
java-version: '11.0.17'
22+
java-version: '8.0.282'
2323
- name: build and test
2424
run: ./gradlew assemble && ./gradlew check --info --stacktrace

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ jobs:
1919
steps:
2020
- uses: actions/checkout@v1
2121
- uses: gradle/wrapper-validation-action@v1
22-
- name: Set up JDK 11
22+
- name: Set up JDK 1.8
2323
uses: actions/setup-java@v1
2424
with:
25-
java-version: '11.0.17'
25+
java-version: '8.0.282'
2626
- name: build test and publish
2727
run: ./gradlew assemble && ./gradlew check --info && ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -x check --info --stacktrace

build.gradle

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ plugins {
1414
id "me.champeau.jmh" version "0.6.6"
1515
}
1616

17-
1817
java {
1918
toolchain {
20-
languageVersion = JavaLanguageVersion.of(11)
21-
19+
languageVersion = JavaLanguageVersion.of(8)
2220
}
2321
}
2422

@@ -51,7 +49,7 @@ def getDevelopmentVersion() {
5149
def reactiveStreamsVersion = '1.0.3'
5250
def slf4jVersion = '1.7.35'
5351
def releaseVersion = System.env.RELEASE_VERSION
54-
def antlrVersion = '4.11.1' // https://mvnrepository.com/artifact/org.antlr/antlr4-runtime
52+
def antlrVersion = '4.9.3' // https://mvnrepository.com/artifact/org.antlr/antlr4-runtime
5553
version = releaseVersion ? releaseVersion : getDevelopmentVersion()
5654
group = 'com.graphql-java'
5755

@@ -150,30 +148,39 @@ shadowJar {
150148
// -removeheaders: Private-Package Removes the MANIFEST.MF header Private-Package, which contains all the internal packages and
151149
// also the repackaged packages like guava, which would be wrong after repackaging.
152150
// Import-Package: Changes the imported packages header, to exclude guava and dependencies from the import list (! excludes packages)
153-
// Guava was repackaged and included inside the jar, so we need remove it.
151+
// Guava was repackaged and included inside the jar, so we need to remove it.
152+
// ANTLR was shaded, so we need to remove it.
153+
// sun.misc is a JRE internal-only class that is not directly used by graphql-java. It was causing problems in libraries using graphql-java.
154154
// The last ,* copies all the existing imports from the other dependencies, which is required.
155155
bnd('''
156156
-exportcontents: graphql.*
157157
-removeheaders: Private-Package
158-
Import-Package: !com.google.*,!org.checkerframework.*,!javax.annotation.*,!graphql.com.google.*,!org.antlr.*,!graphql.org.antlr.*,*
158+
Import-Package: !com.google.*,!org.checkerframework.*,!javax.annotation.*,!graphql.com.google.*,!org.antlr.*,!graphql.org.antlr.*,!sun.misc.*,*
159159
''')
160160
}
161161

162162

163-
task removeNotNeededGuava(type: Zip) {
163+
task extractWithoutGuava(type: Copy) {
164164
from({ zipTree({ "build/libs/graphql-java-${project.version}.jar" }) }) {
165165
exclude('/com/**')
166166
}
167+
into layout.buildDirectory.dir("extract")
168+
}
169+
170+
task buildNewJar(type: Jar) {
171+
from layout.buildDirectory.dir("extract")
167172
archiveFileName = "graphql-java-tmp.jar"
168173
destinationDirectory = file("${project.buildDir}/libs")
174+
manifest {
175+
from file("build/extract/META-INF/MANIFEST.MF")
176+
}
169177
doLast {
170178
delete("build/libs/graphql-java-${project.version}.jar")
171179
file("build/libs/graphql-java-tmp.jar").renameTo(file("build/libs/graphql-java-${project.version}.jar"))
172180
}
173181
}
174182

175-
176-
shadowJar.finalizedBy removeNotNeededGuava
183+
shadowJar.finalizedBy extractWithoutGuava, buildNewJar
177184

178185

179186
task testng(type: Test) {

src/main/java/graphql/collect/ImmutableKit.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import static graphql.Assert.assertNotNull;
1414

1515
@Internal
16+
@SuppressWarnings({"UnstableApiUsage"})
1617
public final class ImmutableKit {
1718

1819
public static <T> ImmutableList<T> emptyList() {
@@ -32,7 +33,6 @@ public static <K, V> ImmutableMap<K, V> addToMap(Map<K, V> existing, K newKey, V
3233
}
3334

3435
public static <T> ImmutableList<T> concatLists(List<T> l1, List<T> l2) {
35-
//noinspection UnstableApiUsage
3636
return ImmutableList.<T>builderWithExpectedSize(l1.size() + l2.size()).addAll(l1).addAll(l2).build();
3737
}
3838

@@ -50,8 +50,7 @@ public static <T> ImmutableList<T> concatLists(List<T> l1, List<T> l2) {
5050
public static <T, R> ImmutableList<R> map(Collection<? extends T> collection, Function<? super T, ? extends R> mapper) {
5151
assertNotNull(collection);
5252
assertNotNull(mapper);
53-
@SuppressWarnings({"RedundantTypeArguments", "UnstableApiUsage"})
54-
ImmutableList.Builder<R> builder = ImmutableList.<R>builderWithExpectedSize(collection.size());
53+
ImmutableList.Builder<R> builder = ImmutableList.builderWithExpectedSize(collection.size());
5554
for (T t : collection) {
5655
R r = mapper.apply(t);
5756
builder.add(r);
@@ -60,21 +59,22 @@ public static <T, R> ImmutableList<R> map(Collection<? extends T> collection, Fu
6059
}
6160

6261
/**
63-
* This will map an iterable of items but drop any that are null from the mapped list
64-
*
62+
* This will map a collection of items but drop any that are null from the input.
6563
* This is more efficient than `c.stream().map().collect()` because it does not create the intermediate objects needed
6664
* for the flexible style. Benchmarking has shown this to outperform `stream()`.
6765
*
68-
* @param iterable the iterable to map
66+
* @param collection the collection to map
6967
* @param mapper the mapper function
7068
* @param <T> for two
7169
* @param <R> for result
7270
*
7371
* @return a map immutable list of results
7472
*/
75-
public static <T, R> ImmutableList<R> mapAndDropNulls(Iterable<? extends T> iterable, Function<? super T, ? extends R> mapper) {
76-
ImmutableList.Builder<R> builder = ImmutableList.builder();
77-
for (T t : iterable) {
73+
public static <T, R> ImmutableList<R> mapAndDropNulls(Collection<? extends T> collection, Function<? super T, ? extends R> mapper) {
74+
assertNotNull(collection);
75+
assertNotNull(mapper);
76+
ImmutableList.Builder<R> builder = ImmutableList.builderWithExpectedSize(collection.size());
77+
for (T t : collection) {
7878
R r = mapper.apply(t);
7979
if (r != null) {
8080
builder.add(r);
@@ -83,7 +83,6 @@ public static <T, R> ImmutableList<R> mapAndDropNulls(Iterable<? extends T> iter
8383
return builder.build();
8484
}
8585

86-
8786
/**
8887
* This constructs a new Immutable list from an existing collection and adds a new element to it.
8988
*
@@ -99,7 +98,6 @@ public static <T> ImmutableList<T> addToList(Collection<? extends T> existing, T
9998
assertNotNull(existing);
10099
assertNotNull(newValue);
101100
int expectedSize = existing.size() + 1 + extraValues.length;
102-
@SuppressWarnings("UnstableApiUsage")
103101
ImmutableList.Builder<T> newList = ImmutableList.builderWithExpectedSize(expectedSize);
104102
newList.addAll(existing);
105103
newList.add(newValue);
@@ -124,7 +122,6 @@ public static <T> ImmutableSet<T> addToSet(Collection<? extends T> existing, T n
124122
assertNotNull(existing);
125123
assertNotNull(newValue);
126124
int expectedSize = existing.size() + 1 + extraValues.length;
127-
@SuppressWarnings("UnstableApiUsage")
128125
ImmutableSet.Builder<T> newSet = ImmutableSet.builderWithExpectedSize(expectedSize);
129126
newSet.addAll(existing);
130127
newSet.add(newValue);

src/main/java/graphql/execution/instrumentation/ExecutionStrategyInstrumentationContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import graphql.Internal;
55
import graphql.PublicSpi;
66
import graphql.execution.FieldValueInfo;
7+
import org.jetbrains.annotations.NotNull;
78

8-
import javax.annotation.Nonnull;
99
import java.util.List;
1010
import java.util.concurrent.CompletableFuture;
1111

@@ -27,7 +27,7 @@ default void onFieldValuesException() {
2727
*
2828
* @return a non null {@link InstrumentationContext} that maybe a no-op
2929
*/
30-
@Nonnull
30+
@NotNull
3131
@Internal
3232
static ExecutionStrategyInstrumentationContext nonNullCtx(ExecutionStrategyInstrumentationContext nullableContext) {
3333
return nullableContext == null ? NOOP : nullableContext;

src/main/java/graphql/execution/instrumentation/SimpleInstrumentationContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package graphql.execution.instrumentation;
22

33
import graphql.PublicApi;
4+
import org.jetbrains.annotations.NotNull;
45

5-
import javax.annotation.Nonnull;
66
import java.util.concurrent.CompletableFuture;
77
import java.util.function.BiConsumer;
88
import java.util.function.Consumer;
@@ -43,7 +43,7 @@ public static <T> InstrumentationContext<T> noOp() {
4343
*
4444
* @return a non null {@link InstrumentationContext} that maybe a no-op
4545
*/
46-
@Nonnull
46+
@NotNull
4747
public static <T> InstrumentationContext<T> nonNullCtx(InstrumentationContext<T> nullableContext) {
4848
return nullableContext == null ? noOp() : nullableContext;
4949
}

src/main/java/graphql/parser/GraphqlAntlrToLanguage.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package graphql.parser;
22

3-
43
import com.google.common.collect.ImmutableList;
54
import graphql.Assert;
65
import graphql.Internal;
@@ -68,8 +67,8 @@
6867
import org.antlr.v4.runtime.ParserRuleContext;
6968
import org.antlr.v4.runtime.Token;
7069
import org.antlr.v4.runtime.tree.TerminalNode;
70+
import org.jetbrains.annotations.Nullable;
7171

72-
import javax.annotation.Nullable;
7372
import java.math.BigDecimal;
7473
import java.math.BigInteger;
7574
import java.util.ArrayList;

src/main/java/graphql/schema/GraphQLEnumType.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package graphql.schema;
22

3-
43
import com.google.common.collect.ImmutableList;
54
import com.google.common.collect.ImmutableMap;
65
import graphql.DirectivesUtil;
@@ -14,8 +13,8 @@
1413
import graphql.util.FpKit;
1514
import graphql.util.TraversalControl;
1615
import graphql.util.TraverserContext;
16+
import org.jetbrains.annotations.NotNull;
1717

18-
import javax.annotation.Nonnull;
1918
import java.util.ArrayList;
2019
import java.util.LinkedHashMap;
2120
import java.util.List;
@@ -149,7 +148,7 @@ private ImmutableMap<String, GraphQLEnumValueDefinition> buildMap(List<GraphQLEn
149148
(fld1, fld2) -> assertShouldNeverHappen("Duplicated definition for field '%s' in type '%s'", fld1.getName(), this.name)));
150149
}
151150

152-
private Object getValueByName(@Nonnull Object value, GraphQLContext graphQLContext, Locale locale) {
151+
private Object getValueByName(@NotNull Object value, GraphQLContext graphQLContext, Locale locale) {
153152
GraphQLEnumValueDefinition enumValueDefinition = valueDefinitionMap.get(value.toString());
154153
if (enumValueDefinition != null) {
155154
return enumValueDefinition.getValue();

0 commit comments

Comments
 (0)