Skip to content

Commit f51d89f

Browse files
committed
Merge branch 'master' of https://github.com/micronaut-projects/micronaut-core into pr-2487
2 parents c8f5f96 + f5668a8 commit f51d89f

File tree

132 files changed

+3866
-2501
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+3866
-2501
lines changed

.github/workflows/branch.yml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ on:
33
push:
44
branches-ignore:
55
- master
6-
- 1.2.x
76
jobs:
87
build:
98
runs-on: ubuntu-latest

.github/workflows/gradle.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ on:
33
push:
44
branches:
55
- master
6-
- 1.2.x
76
pull_request:
87
branches:
98
- master
10-
- 1.2.x
119
jobs:
1210
build:
1311
runs-on: ubuntu-latest
@@ -22,20 +20,26 @@ jobs:
2220
key: ${{ runner.os }}-micronaut-core-gradle-${{ hashFiles('**/*.gradle') }}
2321
restore-keys: |
2422
${{ runner.os }}-micronaut-core-gradle-
23+
- uses: actions/cache@v1
24+
with:
25+
path: ~/.gradle/wrapper
26+
key: ${{ runner.os }}-micronaut-core-wrapper-${{ hashFiles('**/*.gradle') }}
27+
restore-keys: |
28+
${{ runner.os }}-micronaut-core-wrapper-
2529
- name: Set up JDK
2630
uses: actions/setup-java@v1
2731
with:
2832
java-version: ${{ matrix.java }}
2933
- name: Build with Gradle
30-
run: ./gradlew check --no-daemon --parallel --continue --build-cache
34+
run: ./gradlew check --no-daemon --parallel --continue
3135
- name: Publish to JFrog OSS
3236
if: success() && github.event_name == 'push' && matrix.java == '8'
3337
env:
3438
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
3539
BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}
36-
run: ./gradlew publish docs --no-daemon --build-cache
40+
run: ./gradlew publish docs --no-daemon
3741
- name: Publish to Github Pages
38-
if: success() && github.event_name == 'push' && matrix.java == '8' && github.ref == 'master'
42+
if: success() && github.event_name == 'push' && matrix.java == '8'
3943
uses: micronaut-projects/micronaut-docs-deploy@master
4044
env:
4145
GH_TOKEN: ${{ secrets.GH_TOKEN }}

aop/src/main/java/io/micronaut/aop/writer/AopProxyWriter.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import io.micronaut.core.naming.NameUtils;
3232
import io.micronaut.core.reflect.ReflectionUtils;
3333
import io.micronaut.core.util.ArrayUtils;
34+
import io.micronaut.core.util.CollectionUtils;
3435
import io.micronaut.core.value.OptionalValues;
3536
import io.micronaut.inject.BeanDefinition;
3637
import io.micronaut.inject.ExecutableMethod;
@@ -519,9 +520,10 @@ private void visitAroundMethod(Object declaringType,
519520
bridgeArguments.add(proxyFullName);
520521
bridgeArguments.addAll(argumentTypeList);
521522
String bridgeDesc = getMethodDescriptor(returnType, bridgeArguments);
523+
boolean isSuspend = "kotlin.coroutines.Continuation".equals(CollectionUtils.last(argumentTypes.values()));
522524

523525
ExecutableMethodWriter executableMethodWriter = new ExecutableMethodWriter(
524-
proxyFullName, methodExecutorClassName, methodProxyShortName, isInterface, isAbstract, annotationMetadata) {
526+
proxyFullName, methodExecutorClassName, methodProxyShortName, isInterface, isAbstract, isSuspend, annotationMetadata) {
525527

526528
@Override
527529
protected void buildInvokeMethod(Type declaringTypeObject, String methodName, Object returnType, Collection<Object> argumentTypes, GeneratorAdapter invokeMethodVisitor) {

benchmarks/build.gradle

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
plugins {
2-
id "me.champeau.gradle.jmh" version "0.4.8"
2+
id "me.champeau.gradle.jmh" version "0.5.0"
33
}
44

55
dependencies {
66
annotationProcessor project(":inject-java")
7+
jmhAnnotationProcessor project(":inject-java")
8+
jmhAnnotationProcessor "org.ow2.asm:asm:$asmVersion"
9+
jmhAnnotationProcessor "org.ow2.asm:asm-commons:$asmVersion"
10+
711
annotationProcessor project(":validation")
812
compileOnly project(":validation")
913
api project(":inject")
1014
api project(":inject-java-test")
1115
api project(":validation")
16+
api project(":http-server")
17+
api project(":router")
1218
api project(":runtime")
1319

1420
jmh 'org.openjdk.jmh:jmh-core:1.22'
1521
jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.22'
1622
}
1723
jmh {
18-
include =['io.micronaut.aop.around.AroundCompileBenchmark']
24+
include =['io.micronaut.http.server.StartupBenchmark']
1925
duplicateClassesStrategy = 'warn'
2026
warmupIterations = 2
21-
iterations = 4
27+
iterations = 3
2228
fork = 1
2329
// jvmArgs = ["-agentpath:/Applications/YourKit-Java-Profiler-2018.04.app/Contents/Resources/bin/mac/libyjpagent.jnilib"]
2430
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package io.micronaut.http.server;
2+
3+
import io.micronaut.context.ApplicationContext;
4+
import io.micronaut.http.server.binding.TestController;
5+
import org.openjdk.jmh.annotations.Benchmark;
6+
import org.openjdk.jmh.annotations.Scope;
7+
import org.openjdk.jmh.annotations.State;
8+
9+
@State(Scope.Benchmark)
10+
public class StartupBenchmark {
11+
12+
@Benchmark
13+
public void startup() {
14+
try (ApplicationContext context = ApplicationContext.run()) {
15+
final TestController controller =
16+
context.getBean(TestController.class);
17+
}
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package io.micronaut.http.server.binding;
2+
3+
import io.micronaut.aop.around.AroundCompileBenchmark;
4+
import io.micronaut.context.ApplicationContext;
5+
import io.micronaut.http.HttpRequest;
6+
import io.micronaut.http.MutableHttpRequest;
7+
import io.micronaut.web.router.RouteMatch;
8+
import io.micronaut.web.router.Router;
9+
import io.micronaut.web.router.UriRouteMatch;
10+
import org.openjdk.jmh.annotations.Benchmark;
11+
import org.openjdk.jmh.annotations.Scope;
12+
import org.openjdk.jmh.annotations.Setup;
13+
import org.openjdk.jmh.annotations.State;
14+
import org.openjdk.jmh.runner.Runner;
15+
import org.openjdk.jmh.runner.RunnerException;
16+
import org.openjdk.jmh.runner.options.Options;
17+
import org.openjdk.jmh.runner.options.OptionsBuilder;
18+
19+
@State(Scope.Benchmark)
20+
public class RequestArgumentSatisfierBenchmark {
21+
22+
ApplicationContext applicationContext;
23+
RequestArgumentSatisfier requestArgumentSatisfier;
24+
Router router;
25+
26+
@Setup
27+
public void setup() {
28+
applicationContext = ApplicationContext.run();
29+
requestArgumentSatisfier = applicationContext.getBean(RequestArgumentSatisfier.class);
30+
router = applicationContext.getBean(Router.class);
31+
}
32+
33+
@Benchmark
34+
public void benchmarkFulfillArgumentRequirements() {
35+
final MutableHttpRequest<Object> request = HttpRequest.GET("/arguments/foo/bar/10");
36+
final UriRouteMatch<Object, Object> routeMatch = router.find(request.getMethod(), request.getUri(), request).findFirst().orElse(null);
37+
final RouteMatch<?> transformed = requestArgumentSatisfier.fulfillArgumentRequirements(
38+
routeMatch,
39+
request,
40+
true
41+
);
42+
}
43+
44+
public static void main(String[] args) throws RunnerException {
45+
Options opt = new OptionsBuilder()
46+
.include(".*" + AroundCompileBenchmark.class.getSimpleName() + ".*")
47+
.warmupIterations(3)
48+
.measurementIterations(5)
49+
.forks(1)
50+
// .jvmArgs("-agentpath:/Applications/YourKit-Java-Profiler-2018.04.app/Contents/Resources/bin/mac/libyjpagent.jnilib")
51+
.build();
52+
53+
new Runner(opt).run();
54+
}
55+
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package io.micronaut.http.server.binding;
2+
3+
import io.micronaut.http.annotation.Controller;
4+
import io.micronaut.http.annotation.Get;
5+
6+
@Controller("/arguments")
7+
public class TestController {
8+
9+
@Get("/foo/{name}/{age}")
10+
String show(String name, int age) {
11+
return name + " is " + age;
12+
}
13+
}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<configuration>
2+
3+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4+
<!-- encoders are assigned the type
5+
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
6+
<encoder>
7+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
8+
</encoder>
9+
</appender>
10+
11+
<root level="info">
12+
<appender-ref ref="STDOUT" />
13+
</root>
14+
</configuration>

build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,8 @@ subprojects { Project subproject ->
657657

658658
tasks.withType(Test) {
659659
jvmArgs '-Duser.country=US', '-Duser.language=en', '-Xmx2048m'
660-
reports.html.enabled = !System.getenv("TRAVIS")
661-
reports.junitXml.enabled = !System.getenv("TRAVIS")
660+
reports.html.enabled = !System.getenv("GITHUB_ACTIONS")
661+
reports.junitXml.enabled = !System.getenv("GITHUB_ACTIONS")
662662
testLogging {
663663
exceptionFormat = 'full'
664664
}
@@ -672,8 +672,8 @@ subprojects { Project subproject ->
672672

673673
tasks.withType(Checkstyle) {
674674
reports {
675-
xml.enabled = !System.getenv("TRAVIS")
676-
html.enabled = !System.getenv("TRAVIS")
675+
xml.enabled = !System.getenv("GITHUB_ACTIONS")
676+
html.enabled = !System.getenv("GITHUB_ACTIONS")
677677
}
678678
}
679679

core/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ dependencies {
1010
api dependencyVersion("slf4j")
1111
api dependencyVersion("reactive.streams")
1212
api dependencyVersion("jsr305")
13-
13+
compileOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
14+
1415
compileOnly "org.ow2.asm:asm-tree:$asmVersion"
1516
shadowCompile "org.ow2.asm:asm:$asmVersion"
1617
shadowCompile "org.ow2.asm:asm-commons:$asmVersion"

core/src/main/java/io/micronaut/core/annotation/AnnotationClassValue.java

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
@UsedByGeneratedCode
3434
public final class AnnotationClassValue<T> implements CharSequence, Named {
3535

36+
/**
37+
* An empty array of class values.
38+
*/
39+
public static final AnnotationClassValue<?>[] EMPTY_ARRAY = new AnnotationClassValue[0];
40+
3641
private final String name;
3742
private final Class<T> theClass;
3843
private final T instance;

core/src/main/java/io/micronaut/core/annotation/AnnotationValue.java

+30
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,36 @@ public Class<?>[] classValues(@Nonnull String member) {
358358
return ReflectionUtils.EMPTY_CLASS_ARRAY;
359359
}
360360

361+
@Nonnull
362+
@Override
363+
public AnnotationClassValue<?>[] annotationClassValues(@Nonnull String member) {
364+
if (StringUtils.isNotEmpty(member)) {
365+
Object o = values.get(member);
366+
if (o instanceof AnnotationClassValue) {
367+
return new AnnotationClassValue[] {(AnnotationClassValue) o};
368+
} else if (o instanceof AnnotationClassValue[]) {
369+
return (AnnotationClassValue<?>[]) o;
370+
}
371+
}
372+
return AnnotationClassValue.EMPTY_ARRAY;
373+
}
374+
375+
@Override
376+
public Optional<AnnotationClassValue<?>> annotationClassValue(@Nonnull String member) {
377+
if (StringUtils.isNotEmpty(member)) {
378+
Object o = values.get(member);
379+
if (o instanceof AnnotationClassValue) {
380+
return Optional.of((AnnotationClassValue<?>) o);
381+
} else if (o instanceof AnnotationClassValue[]) {
382+
AnnotationClassValue[] a = (AnnotationClassValue[]) o;
383+
if (a.length > 0) {
384+
return Optional.of(a[0]);
385+
}
386+
}
387+
}
388+
return Optional.empty();
389+
}
390+
361391
/**
362392
* The integer value of the given member.
363393
*

core/src/main/java/io/micronaut/core/annotation/AnnotationValueResolver.java

+20-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ default Optional<Class<?>> classValue() {
9090
/**
9191
* The value of the annotation as a Class.
9292
*
93-
* @return An {@link Optional} class
93+
* @return An array of classes
9494
*/
9595
@Nonnull
9696
default Class<?>[] classValues() {
@@ -101,10 +101,28 @@ default Class<?>[] classValues() {
101101
* The value of the given annotation member as a Class.
102102
*
103103
* @param member The annotation member
104-
* @return An {@link Optional} class
104+
* @return An array of classes
105105
*/
106106
@Nonnull Class<?>[] classValues(@Nonnull String member);
107107

108+
109+
/**
110+
* The {@link AnnotationClassValue} instances for the given member. Unlike {@link #classValues(String)} this may
111+
* include classes that are no the classpath.
112+
*
113+
* @param member The annotation member
114+
* @return An array of class values
115+
*/
116+
@Nonnull AnnotationClassValue<?>[] annotationClassValues(@Nonnull String member);
117+
118+
/**
119+
* The {@link AnnotationClassValue} instance for the given member.
120+
*
121+
* @param member The annotation member
122+
* @return An annotation class value
123+
*/
124+
Optional<AnnotationClassValue<?>> annotationClassValue(@Nonnull String member);
125+
108126
/**
109127
* The integer value of the given member.
110128
*

0 commit comments

Comments
 (0)