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

Karate mock-server fails to load proper contextClassLoader when watch is set to true #2287

Closed
alexjaravete opened this issue Mar 28, 2023 · 3 comments
Assignees
Milestone

Comments

@alexjaravete
Copy link

alexjaravete commented Mar 28, 2023

I want to use karate mock with a custom library that I created. If I run karate mock without the watch feature it works without any issues. When I enable it, it can sometimes happen that the ContextClassLoader in Suite.java is null. It does not always happen, but only when I start the changing the feature file. And even then it does not happen on every refresh but only on some.

classLoader = Thread.currentThread().getContextClassLoader();

You can try to reproduce it by creating a MockServer in a Java project and set watch to true. Then add a debug point with a null check in Suite when the classloader is set. Now keep changing something in the feature file and keep making calls to the mock server.

Could we add a check if the ContextClassLoader is null and then call the getClass().getClassLoader()if it's null?
Thanks!

@ptrthomas
Copy link
Member

@ajaravete thanks for the analysis ! do you think you can submit a PR. that will be the fastest way we can get this into the next release

@alexjaravete
Copy link
Author

Yes I will create one and link it here.

ptrthomas added a commit that referenced this issue Mar 30, 2023
ptrthomas added a commit that referenced this issue Mar 30, 2023
@ptrthomas ptrthomas added this to the 1.4.0 milestone Mar 30, 2023
@ptrthomas
Copy link
Member

1.4.0 released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants