Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting exception Retrieving groups by name is not supported on this platform #33

Closed
mih-kopylov opened this issue Apr 4, 2019 · 3 comments
Labels
Bug Something isn't working

Comments

@mih-kopylov
Copy link

Setup information

java version: 11
hikaku version: 2.1.0
build tool and version: maven 3.5.4
test framework: junit 4.12

Describe the bug

Running the following test

    @Test
    public void testApi() throws URISyntaxException {
        final HikakuConfig config = new HikakuConfig(Set.of(SpringConverter.IGNORE_ERROR_ENDPOINT));
        final Path path = Paths.get(getClass().getClassLoader().getResource("openapi.yml").toURI());
        new Hikaku(new OpenApiConverter(path), new SpringConverter(applicationContext), config).match();
    }

Expected behavior

API matching test result

Actual result

Exception stacktrace:

de.codecentric.hikaku.converters.EndpointConverterException: Retrieving groups by name is not supported on this platform.

	at de.codecentric.hikaku.converters.openapi.OpenApiConverter.convert(OpenApiConverter.kt:45)
	at de.codecentric.hikaku.converters.AbstractEndpointConverter$conversionResult$2.invoke(AbstractEndpointConverter.kt:11)
	at de.codecentric.hikaku.converters.AbstractEndpointConverter$conversionResult$2.invoke(AbstractEndpointConverter.kt:8)
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
	at de.codecentric.hikaku.converters.AbstractEndpointConverter.getConversionResult(AbstractEndpointConverter.kt)
	at de.codecentric.hikaku.Hikaku.match(Hikaku.kt:39)
	at com.example.Api_IT.testApi(Api_IT.java:30)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)
	at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.UnsupportedOperationException: Retrieving groups by name is not supported on this platform.
	at kotlin.internal.jdk8.JDK8PlatformImplementations.getMatchResultNamedGroup(JDK8PlatformImplementations.kt:28)
	at kotlin.text.MatcherMatchResult$groups$1.get(Regex.kt:259)
	at kotlin.text.jdk8.RegexExtensionsJDK8Kt.get(RegexExtensions.kt:33)
	at de.codecentric.hikaku.converters.openapi.extractors.QueryParameterExtractor.extractQueryParametersFromComponents(QueryParameterExtractor.kt:32)
	at de.codecentric.hikaku.converters.openapi.extractors.QueryParameterExtractor.invoke(QueryParameterExtractor.kt:13)
	at de.codecentric.hikaku.converters.openapi.OpenApiConverter.parseOpenApi(OpenApiConverter.kt:65)
	at de.codecentric.hikaku.converters.openapi.OpenApiConverter.convert(OpenApiConverter.kt:43)
	... 36 more
@mih-kopylov mih-kopylov added the Bug Something isn't working label Apr 4, 2019
@cc-jhr
Copy link
Collaborator

cc-jhr commented Apr 5, 2019

Hello @mih-kopylov,

thank you for reporting this issue.

When hikaku tries to exctract the query parameters from your OpenAPI specification it uses a regex with a named group. So calling groups.get("key") throws the exception in the stacktrace you posted.

Retrieving groups by name is not supported on this platform.

It originates from UnsupportedOperationException. The test cases for this part are successful on both jdk8 and jdk11. However the behavior seems to be similar to this issue. As far as I can see this has been resolved for kotlin 1.3.20.

So my assumption is that your classpath might contain a kotlin-stdlib-jre8 having a version < 1.3.20. Could you please verify the versions of the kotlin related dependencies in your actual classpath?

Is the described behavior the same for running the tests via CLI and IDE?

@cc-jhr
Copy link
Collaborator

cc-jhr commented Apr 30, 2019

@mih-kopylov have you been able to confirm this? Any new insights?

@cc-jhr
Copy link
Collaborator

cc-jhr commented May 6, 2019

I am unable to reproduce this and haven't heard from you in a month so I am closing this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants