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

Ensure that a non-indexed entry doesn't break generic type resolution #16727

Merged
merged 2 commits into from
Apr 28, 2021

Conversation

geoand
Copy link
Contributor

@geoand geoand commented Apr 22, 2021

This can happen if say some interface extends a JDK interface and there
is no reason the type resolution should fail because of it

@geoand geoand requested a review from FroMage April 22, 2021 13:20
@geoand
Copy link
Contributor Author

geoand commented Apr 22, 2021

cc @lburgazzoli who initially brought this to me

@geoand geoand changed the title Ensure that a non-indexed leaf doesn't break generic type resolution Ensure that a non-indexed entry doesn't break generic type resolution Apr 22, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Apr 22, 2021

This workflow status is outdated as a new workflow run has been triggered.

Failing Jobs - Building 6f1268a

Status Name Step Test failures Logs Raw logs
JVM Tests - JDK 11 Build Test failures Logs Raw logs
✔️ JVM Tests - JDK 15

Full information is available in the Build summary check run.

Test Failures

⚙️ JVM Tests - JDK 11 #

📦 extensions/jdbc/jdbc-mysql/deployment

io.quarkus.jdbc.mysql.deployment.DevServicesMySQLDatasourceTestCase.testDatasource - More details - Source on GitHub

Copy link
Member

@FroMage FroMage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't understand the change.

What I think this is doing is that for external callers to findParametersRecursively this will still throw if not found, but if it recurses inside, it will return null instead.

So… I assume fetchFromIndex is the one doing the throwing, and then it will only throw for the first-level call, not for any recursion?

@geoand
Copy link
Contributor Author

geoand commented Apr 23, 2021

What I think this is doing is that for external callers to findParametersRecursively this will still throw if not found, but if it recurses inside, it will return null instead.

What external callers?

So… I assume fetchFromIndex is the one doing the throwing, and then it will only throw for the first-level call, not for any recursion?

Yes, fetchFromIndex is the method that throws.

My whole point is that I don't want th exception to terminal when looking up superclasses or interfaces

@FroMage
Copy link
Member

FroMage commented Apr 23, 2021

What external callers?

The function that calls it the first time. It's not going to just call itself ;)

My whole point is that I don't want th exception to terminal when looking up superclasses or interfaces

OK. Got it.

My only worry is that this is changing the behaviour for all users of that method, and so it may be hiding the cause of a further error.

I think there are two cases where we can fail to find the parameter recursively:

  • It's in a super class that is missing from the index, we won't find it anywhere else and the user must know that we failed to find it because the super class should be indexed.
  • It's not in a super class, which is missing anyway, and we can go on and find it later from another super class that is indexed.

I think you've treated the second case. I worry about the first case, because the result is that we'll tell the user we could not find the parameter (it will be null) but we won't be able to tell him why (the class Foo was not indexed).

OTOH, if the contract of the external caller to findParametersRecursively is that it can return null and that's not an error, then perhaps we never want any exception. But I don't think that's the case. I think the null return value is only valid for recursion calls, to allow further lookup.

So perhaps the safer thing to do is to record which types are not indexed during recursion, and keep going. If at the end of the external call we have a result, then ignore all those not-indexed errors. If we don't, then raise an error explaining which types were not indexed that could be the cause of this error?

WDYT?

@geoand
Copy link
Contributor Author

geoand commented Apr 23, 2021

What external callers?

The function that calls it the first time. It's not going to just call itself ;)

My whole point is that I don't want th exception to terminal when looking up superclasses or interfaces

OK. Got it.

My only worry is that this is changing the behaviour for all users of that method, and so it may be hiding the cause of a further error.

I think there are two cases where we can fail to find the parameter recursively:

  • It's in a super class that is missing from the index, we won't find it anywhere else and the user must know that we failed to find it because the super class should be indexed.
  • It's not in a super class, which is missing anyway, and we can go on and find it later from another super class that is indexed.

I think you've treated the second case. I worry about the first case, because the result is that we'll tell the user we could not find the parameter (it will be null) but we won't be able to tell him why (the class Foo was not indexed).

OTOH, if the contract of the external caller to findParametersRecursively is that it can return null and that's not an error, then perhaps we never want any exception. But I don't think that's the case. I think the null return value is only valid for recursion calls, to allow further lookup.

Yes, I completely agree

So perhaps the safer thing to do is to record which types are not indexed during recursion, and keep going. If at the end of the external call we have a result, then ignore all those not-indexed errors. If we don't, then raise an error explaining which types were not indexed that could be the cause of this error?

WDYT?

Sure yeah, that makes sense. I'll update the PR on Monday

@FroMage
Copy link
Member

FroMage commented Apr 23, 2021

OK great, no rush :)

@geoand geoand force-pushed the safe-type-resolution branch from 6f1268a to 553bf19 Compare April 26, 2021 09:08
@geoand
Copy link
Contributor Author

geoand commented Apr 26, 2021

PR updated as per your suggestion and tests added

@geoand geoand requested a review from FroMage April 26, 2021 09:08
@quarkus-bot
Copy link

quarkus-bot bot commented Apr 26, 2021

This workflow status is outdated as a new workflow run has been triggered.

Failing Jobs - Building 553bf19

Status Name Step Test failures Logs Raw logs
JVM Tests - JDK 11 Build Test failures Logs Raw logs
JVM Tests - JDK 11 Windows Build ⚠️ Check → Logs Raw logs
JVM Tests - JDK 15 Build Test failures Logs Raw logs
MicroProfile TCKs Tests Verify Test failures Logs Raw logs
Native Tests - Spring Build ⚠️ Check → Logs Raw logs

Full information is available in the Build summary check run.

Test Failures

⚙️ JVM Tests - JDK 11 #

📦 integration-tests/spring-web

io.quarkus.it.spring.web.TestSecurityTest.testPreAuthorizeWithDisabledAuth - More details - Source on GitHub


⚙️ JVM Tests - JDK 15 #

📦 integration-tests/spring-web

io.quarkus.it.spring.web.TestSecurityTest.testPreAuthorizeWithDisabledAuth - More details - Source on GitHub


⚙️ MicroProfile TCKs Tests #

📦 tcks/resteasy-reactive/target/testsuite/tests

com.sun.ts.tests.jaxrs.spec.filter.interceptor.JAXRSClient0021. - More details - Source on GitHub

Copy link
Member

@FroMage FroMage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@geoand geoand force-pushed the safe-type-resolution branch from 553bf19 to a49d919 Compare April 28, 2021 09:24
@geoand geoand added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Apr 28, 2021
@geoand
Copy link
Contributor Author

geoand commented Apr 28, 2021

It seems like the failure in JAXRSClient0021 is actually caused by this...

geoand added 2 commits April 28, 2021 13:58
This can happen if say some interface extends a JDK interface and there
is no reason the type resolution should fail because of it
@geoand geoand force-pushed the safe-type-resolution branch from a49d919 to c06abd3 Compare April 28, 2021 10:59
@geoand
Copy link
Contributor Author

geoand commented Apr 28, 2021

Fixed

@quarkus-bot
Copy link

quarkus-bot bot commented Apr 28, 2021

This workflow status is outdated as a new workflow run has been triggered.

🚫 This workflow run has been cancelled.

Failing Jobs - Building a49d919

⚠️ Artifacts of the workflow run were not available thus the report misses some details.

Status Name Step Test failures Logs Raw logs
Devtools Tests - JDK 11 Windows Build Test failures Logs Raw logs
JVM Tests - JDK 11 Build ⚠️ Check → Logs Raw logs
JVM Tests - JDK 11 Windows Build ⚠️ Check → Logs Raw logs
JVM Tests - JDK 15 Build ⚠️ Check → Logs Raw logs
MicroProfile TCKs Tests Verify Test failures Logs Raw logs
Native Tests - Spring Build ⚠️ Check → Logs Raw logs
Native Tests - gRPC Build ⚠️ Check → Logs Raw logs

Full information is available in the Build summary check run.

Test Failures

⚙️ Devtools Tests - JDK 11 Windows #

📦 integration-tests/devtools

io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartBuildIT.testRunTogetherCodestartsKotlin line 61 - More details - Source on GitHub


⚙️ MicroProfile TCKs Tests #

📦 tcks/resteasy-reactive/target/testsuite/tests

com.sun.ts.tests.jaxrs.spec.filter.interceptor.JAXRSClient0021. - More details - Source on GitHub

@quarkus-bot
Copy link

quarkus-bot bot commented Apr 28, 2021

Failing Jobs - Building c06abd3

Status Name Step Test failures Logs Raw logs
✔️ JVM Tests - JDK 11
JVM Tests - JDK 11 Windows Build Test failures Logs Raw logs
✔️ JVM Tests - JDK 15

Full information is available in the Build summary check run.

Test Failures

⚙️ JVM Tests - JDK 11 Windows #

📦 extensions/arc/deployment

io.quarkus.arc.test.config.ConfigMappingTest. - More details - Source on GitHub

@geoand geoand merged commit 24c5b7f into quarkusio:main Apr 28, 2021
@quarkus-bot quarkus-bot bot added this to the 2.0 - main milestone Apr 28, 2021
@geoand geoand deleted the safe-type-resolution branch April 28, 2021 13:48
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants