-
Notifications
You must be signed in to change notification settings - Fork 165
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
Update classgraph dependency to start up in low-memory environments #762
Conversation
…memory environments See classgraph/classgraph#400 for more details.
@michael-simons I also noticed that the last change to this was #735 and this comment (from an earlier time): neo4j-ogm/core/src/main/java/org/neo4j/ogm/metadata/DomainInfo.java Lines 84 to 86 in 5baa143
Sounds like your work could be related to a fix in 4.8.62:
and also maybe is an outdated comment since the code after it does use |
Yes, that comment is outdated, as the issue with classloading was fixed after this report by @michael-simons: Please ensure you test ClassGraph 4.8.64 with Neo4J-OGM thoroughly before pushing out a release to your users, as this release contains some of the deepest changes that ClassGraph has undergone in a long time. All the unit tests pass fine on all platforms with this latest verison; however, I want to ensure there is no disruption to Neo4J-OGM users. (Apologies for the couple of recent disruptions that Neo4J-OGM has run into as a result of ClassGraph changes!) |
Hey everyone. First of all, I absolutely love the thoughts, work and effort put in this ticket and the issues on Classgraph. I'm gonna grab that branch here and build it on our CI. Will take me a bit… |
Re
Yes, we use Classgraph, but only the scanning features at the moment and use our own class loader configuration. neo4j-ogm/core/src/main/java/org/neo4j/ogm/metadata/DomainInfo.java Lines 87 to 91 in 5baa143
While I noticed that Luke fixed the issues we had (thanks for that), we decided it would be better to take the class loading issues into our responsibility, so that we can make configurable in the future or at least provide a strategy. I'm gonna adapt the comment, though. |
That would be a reasonable thing to do, except that you have to make sure that the classes found by ClassGraph and the classes loaded by your own classloader are not just the same classes (e.g. what if ClassGraph can find some classes that your classloader can't, or vice versa?), but the same definitions of the same classes (i.e. that classpath elements are processed in the same order, so you don't get ClassGraph scanning one version of a class and your classloader loading a different version of the class). This has been a source of hard-to-trace bugs for some users of ClassGraph in the past. One way you can reconcile what ClassGraph scans with what your context classloader loads is simply to override the classloaders that ClassGraph scans (this also overrides the classpath):
If you do decide to use The only case where |
Thanks, Luke. I tried that right now
But that still breaks further down the line in a Spring Boot reload scenario, as the underlying class loader has been swapped out for a new one. Issue I see in such an application when accessing an entity for example is
I'm rather update class graph (looks good) and stick with our loading for now. |
Fair enough, thanks for trying it. Your situation is unique enough that you should do what you need to do, as long as you understand the caveat that ClassGraph may find different classes from the ones that are loaded. |
Just pushed the improved comment moments before your comment :) |
Just edited my comment moments before you replied :-D |
Just to clarify -- primarily there are three situations:
|
…onments. See classgraph/classgraph#400 for more details. Also be precise in our internal docs why we are not using ClassGraph to load the discovered classes. Co-authored-by: Michael Simons <michael@simons.ac>
[FIX] Workaround until neo4j/neo4j-ogm#762 lands in a release
See classgraph/classgraph#400 for more details.
Description
Bump a version number of
classgraph
so that Neo4J OGM can work in lower-memory setups easily. It should be a minor change as it was updated only 4 releases ago which was a month ago.Related Issue
There's no issue in this repo, the "Background" in classgraph/classgraph#400 is the issue.
Motivation and Context
I'm following up on classgraph/classgraph#400 (comment)
4.8.63 has a fix for an infinite loop on OOM and significantly lowers the memory consumption of classgraph itself. But it doesn't work on JDK7-8, so using the latest 4.8.64 which fixes that compatibility issue.
How Has This Been Tested?
I have a project where I overrode the
classloader
dependency withMy harness integration tests pass and app works as before on JDK 8 and -Xmx64M (previously it was sometimes failing with -Xmx256M and consistently failing with -Xmx128M).
Types of changes
Checklist:
(I still didn't read it as it still doesn't exist... I commented on this in Clean up built-in conversions documentation #501 too :)
I'll leave this up to the CI