Skip to content

Commit

Permalink
Merge branch '3.5.x' into 3.6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
sdelamo committed Jul 27, 2022
2 parents 4e28090 + 20e29a2 commit 8613179
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 24 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/graalvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
strategy:
matrix:
java: ['11', '17']
graalvm: ['latest', 'dev']
steps:
# https://github.com/actions/virtual-environments/issues/709
- name: Free disk space
Expand All @@ -38,7 +39,7 @@ jobs:
- name: Setup GraalVM CE
uses: graalvm/setup-graalvm@v1
with:
version: '22.1.0'
version: ${{ matrix.graalvm }}
java-version: ${{ matrix.java }}
components: 'native-image'
- name: Build with Gradle
Expand All @@ -57,7 +58,7 @@ jobs:
PREDICTIVE_TEST_SELECTION: "${{ github.event_name == 'pull_request' && 'true' || 'false' }}"
- name: Publish Test Report
if: always()
uses: mikepenz/action-junit-report@v3.0.3
uses: mikepenz/action-junit-report@v3.1.0
with:
check_name: GraalVM CE CI / Test Report (Java ${{ matrix.java }})
report_paths: '**/build/test-results/test/TEST-*.xml'
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,17 @@ jobs:
PREDICTIVE_TEST_SELECTION: "${{ github.event_name == 'pull_request' && 'true' || 'false' }}"
- name: Publish Test Report
if: always()
uses: mikepenz/action-junit-report@v3.0.3
uses: mikepenz/action-junit-report@v3.1.0
with:
check_name: Java CI / Test Report (${{ matrix.java }})
report_paths: '**/build/test-results/test/TEST-*.xml'
check_retries: 'true'
- name: "📜 Upload binary compatibility check results"
if: always()
uses: actions/upload-artifact@v2
with:
name: binary-compatibility-reports
path: "**/build/reports/binary-compatibility-*.html"
- name: Publish to Sonatype Snapshots
if: success() && github.event_name == 'push' && matrix.java == '11'
env:
Expand Down
7 changes: 6 additions & 1 deletion core/src/main/java/io/micronaut/core/io/IOUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static void eachFile(@NonNull URI uri, String path, @NonNull Consumer<Pat
// try to match FileSystems.newFileSystem(URI) semantics for zipfs here.
// Basically ignores anything after the !/ if it exists, and uses the part
// before as the jar path to extract.
String jarUri = uri.getSchemeSpecificPart();
String jarUri = uri.getRawSchemeSpecificPart();
int sep = jarUri.lastIndexOf("!/");
if (sep != -1) {
jarUri = jarUri.substring(0, sep);
Expand Down Expand Up @@ -136,6 +136,11 @@ private static Path loadNestedJarUri(List<Closeable> toClose, String jarUri) thr
return Paths.get(URI.create(jarUri));
}
Path jarPath = loadNestedJarUri(toClose, jarUri.substring(0, sep));
if (Files.isDirectory(jarPath)) {
// spring boot creates weird jar URLs, like 'jar:file:/xyz.jar!/BOOT-INF/classes!/abc'
// This check makes our class loading resilient to that
return jarPath;
}
FileSystem zipfs;
try {
// can't use newFileSystem(Path) here (without CL) because it doesn't exist on java 8
Expand Down
60 changes: 60 additions & 0 deletions core/src/test/groovy/io/micronaut/core/io/IOUtilsSpec.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.micronaut.core.io

import org.opentest4j.TestAbortedException
import spock.lang.Issue
import spock.lang.Specification

import java.nio.charset.StandardCharsets
Expand Down Expand Up @@ -66,4 +68,62 @@ class IOUtilsSpec extends Specification {
cleanup:
Files.deleteIfExists(zipPath)
}

def 'weird file name'() {
given:
Path tempDir = Files.createTempDirectory("micronaut-ioutils-spec")
Path file
try {
file = tempDir.resolve("foo?bar.zip")
try (ZipOutputStream zos = new ZipOutputStream(Files.newOutputStream(file))) {
zos.putNextEntry(new ZipEntry("foo/bar.txt"))
zos.write("baz".getBytes(StandardCharsets.UTF_8))
zos.closeEntry()
}
} catch (Exception e) {
throw new TestAbortedException("Failed to create file with weird name (maybe FS doesn't support " +
"the name itself)", e)
}

def visitedOuter = []

when:
IOUtils.eachFile(URI.create('jar:' + file.toUri()), 'foo', entry -> {
visitedOuter.add(entry.getFileName().toString())
})
then:
visitedOuter == ['bar.txt']

cleanup:
if (file != null) {
Files.deleteIfExists(file)
}
Files.deleteIfExists(tempDir)
}

@Issue('https://github.com/grails/grails-core/issues/12625/')
def 'dir inside jar'() {
given:
Path zipPath = Files.createTempFile("micronaut-ioutils-spec", ".zip")
try (ZipOutputStream outer = new ZipOutputStream(Files.newOutputStream(zipPath))) {
outer.putNextEntry(new ZipEntry("foo/bar/baz/test.txt"))
outer.write("bla".getBytes(StandardCharsets.UTF_8))
outer.closeEntry()
}

def visitedInner = []
def textInner = []

when:
IOUtils.eachFile(URI.create('jar:' + zipPath.toUri() + '!/foo/bar!/xyz'), 'baz', entry -> {
visitedInner.add(entry.getFileName().toString())
textInner = Files.readAllLines(entry)
})
then:
visitedInner == ['test.txt']
textInner == ['bla']

cleanup:
Files.deleteIfExists(zipPath)
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ kotlin.stdlib.default.dependency=false

# For the docs
graalVersion=22.0.0.2
micronautSecurityVersion=3.6.0
micronautSecurityVersion=3.6.2

org.gradle.caching=true
org.gradle.parallel=true
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ managed-micronaut-rss = "3.1.0"
managed-micronaut-rxjava1 = "1.0.0"
managed-micronaut-rxjava2 = "1.2.1"
managed-micronaut-rxjava3 = "2.2.1"
managed-micronaut-security = "3.6.1"
managed-micronaut-security = "3.6.2"
managed-micronaut-serialization = "1.2.0"
managed-micronaut-servlet = "3.2.3"
managed-micronaut-spring = "4.2.1"
Expand All @@ -122,13 +122,13 @@ managed-micronaut-tracing = "4.2.0"
managed-micronaut-tracing-legacy = "3.2.7"
managed-micronaut-views = "3.5.0"
managed-micronaut-xml = "3.0.1"
managed-neo4j = "3.5.33"
managed-neo4j = "3.5.34"
managed-neo4j-java-driver = "4.2.7"
managed-netty = "4.1.77.Final"
managed-reactive-pg-client = "0.11.4"
managed-reactive-streams = "1.0.4"
# This should be kept aligned with https://github.com/micronaut-projects/micronaut-reactor/blob/master/gradle.properties from the BOM
managed-reactor = "3.4.18"
managed-reactor = "3.4.21"
managed-rxjava1 = "1.3.8"
managed-rxjava1-interop = "0.13.7"
managed-slf4j = "1.7.36"
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 6 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
14 changes: 8 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.micronaut.inject.beanbuilder

import io.micronaut.annotation.processing.test.AbstractTypeElementSpec
import io.micronaut.context.annotation.Primary
import io.micronaut.inject.qualifiers.Qualifiers
import io.micronaut.inject.visitor.TypeElementVisitor

Expand All @@ -14,12 +15,16 @@ import io.micronaut.context.annotation.Prototype;
@Prototype
class Foo {
}
''')
expect:
context.getBean(OtherBeanProducer.BeanA).name == 'primary'
context.getBean(OtherBeanProducer.BeanA, Qualifiers.byName("other")).name == 'other'
context.getBeanDefinition(OtherBeanProducer.BeanA).hasAnnotation("test.Foo")
!context.getBeanDefinition(OtherBeanProducer.BeanA, Qualifiers.byName("other")).hasAnnotation("test.Foo")
context.getBeanDefinition(OtherBeanProducer.BeanA, Qualifiers.byName("other")).hasAnnotation("test.Bar")
context.getBeanDefinition(OtherBeanProducer.BeanA).hasAnnotation(Primary)

cleanup:
context.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,22 @@ public void visitClass(ClassElement element, VisitorContext context) {
.qualifier(AnnotationValue.builder(Primary.class).build());
final ElementQuery<MethodElement> query = ElementQuery.ALL_METHODS
.annotated((am) -> am.hasAnnotation(TestProduces.class));
beanElementBuilder.produceBeans(query, (builder) ->
builder.withParameters(params ->
params[0].injectValue("primary")
).qualifier(AnnotationValue.builder(Primary.class).build())
beanElementBuilder.produceBeans(query, (builder) -> {
builder.annotate("test.Foo");
builder.withParameters(params ->
params[0].injectValue("primary")
).qualifier(AnnotationValue.builder(Primary.class).build());
}
);

final BeanElementBuilder beanElementBuilder2 = element.addAssociatedBean(producer)
.qualifier("other");
beanElementBuilder2.produceBeans(query, (builder) ->
beanElementBuilder2.produceBeans(query, (builder) -> {
builder.annotate("test.Bar");
builder.withParameters(params ->
params[0].injectValue("other")
).qualifier("other")
);
params[0].injectValue("other")
).qualifier("other");
});
});
}
}
Expand Down

0 comments on commit 8613179

Please sign in to comment.