-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
application-test.properties
leaks into downstream module tests even though only application.properties
is included in the test-jar
#42580
Comments
So it's about prioritizing |
I wouldn't say so, because In other words, if (in this specific test-jar setup) |
Ok, that makes sense. |
I believe the issue is that we use the path of the build directory instead of the compiled jar as one of the entries in the test classloader (most likely to support hot reload of multi-module projects). We would need to look into the dependency configuration to apply the necessary filters for include/exclude. Might be a bit tricky. |
We actually do apply content filtering. I am going to look into it. |
Yes, I know. I was thinking that the tricky part is the surefire configuration. Not sure if we have that implemented. |
Surefire config isn't involved in this. It's artifact content. I'll have a look. |
Ah, I was thinking that we would need to read surefire configuration to exclude / include stuff, but I guess that we can just pick up the test jar artifact and match the content, right? |
The jars might not exist at this phase but we do consult jar plugin configurations already, so it looks like something that should be supported |
The classpath element representing
which is what's expected. So the |
It's coming from |
@aloubyansky does that mean it's beyond Quarkus' control? Is the surefire classpath setup to be blamed? |
It's a quarkus issue. Surefire does what it's supposed to do. I need to spend more time on this. |
@radcortez SR Config will need a fix. When it tries to check whether profile-specific config sources (properties) are available, it creates specific URI and checks whether they happen to be loadable. The issue is that it doesn't check whether they are going beyond the classpath scope. Here is where it happens https://github.com/smallrye/smallrye-config/blob/main/implementation/src/main/java/io/smallrye/config/AbstractLocationConfigSourceLoader.java#L213 The reproducer has both Somehow, the code shouldn't create paths that are crossing boundaries of classpath elements. If Another interesting point, not related to the above issue is that the classpath resources in the In case of |
Just to make it clear, the above is not a Quarkus issue. |
Yes, we require the main file to be present to ensure a consistent ordering when loading the files, and each of the profile files is queried from the main location manually to keep that order. When a resource is in the jar, that is fine, because if the main file is coming from a jar, we generate the equivalent location for a possible profile resource to load from that jar location. It seems it is indeed a problem, if the resource is loaded from a file location, where we need to perform an additional check to make sure that that file is also part of the classloader. It should be fine to perform that check. I'm just not sure how can we do it, because as you said, |
A classpath check would be enough. If maven/surefire/whatever doesn't setup the classpath consistently there is not much we can do besides completely isolating quarkus classloaders. There's not much else we can do. And given we actually pass a class loader to the config builder, that's what a user should expect. |
Ok, if we assume that case, I'm fine adding the check. |
@famod, are you okay with the resolution? Even if I fix the issue discovered in SmallRye Config, you will probably still have the original problem. Maybe you need to add some Maven filtering to control how you want the file to be available / or not. |
Just to clarify, it will work with Note, quarkus properly applies resource filtering in both cases. But surefire doesn't, so it will be loaded from the classpath created by surefire. |
I'd say it's a step in the right direction to add that check in SR Config. I'll see if I can report a surefire issue with a reproducer. |
Confirmed. I'd like to add that |
Describe the bug
Imagine module A providing a
src/test/resources/application.properties
to downstream modules by building a test-jar.Now also image an
application-test.properties
(next to thatapplication.properties
) that is not included in the test-jar (because it is only needed for tests in A but not for any downstream modules).In such a setup, even though
application-test.properties
does not end up in the test-jar, downstream modules adding a dependency to that test-jar still receive config properties from thatapplication-test.properties
.Expected behavior
Only config that is actually in the test-jar is applied to downstream modules.
Actual behavior
application-test.properties
leaks into downstream modulesHow to Reproduce?
q_testjar-properties.zip
./mvnw clean install
foo
property indist
is overridden by thefoo
property in theapplication-test.properties
of upstream modulecore
Output of
uname -a
orver
No response
Output of
java -version
No response
Quarkus version or git rev
3.13.2
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
I went back all the way to 2.7.0.Final (see #22336) and it seems it has always been like that.
The text was updated successfully, but these errors were encountered: