Skip to content

How about replacing java.lang.reflect call with org.springframework.util.ReflectionUtils #2027

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

Closed
AntonLGVS opened this issue Dec 14, 2021 · 2 comments · Fixed by #2033
Closed
Labels
status: feedback-provided Feedback has been provided type: enhancement A general enhancement

Comments

@AntonLGVS
Copy link
Contributor

What do you think about making this replacement?
ReflectionUtils has a cache that allows you to reduce call to the Java Security Manager (Deprecated in Java 17).
As I understand it, this may allow better optimization for the Spring Native (and other Cloud Nantive).
And java.lang.reflect calls is low-level API.

Current classes having calls to java.lang.reflect:

  1. MappingElasticsearchConverter#populateScriptFields
  2. IndexBuilder#buildIndex
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 14, 2021
@sothawo
Copy link
Collaborator

sothawo commented Dec 15, 2021

ad 1: This should be improved: here a ElasticsearchPersistentEntity should be used to get the properties which are annotated with ScriptedField because in Spring Data Elasticsearch this is where all the reflective access to the entity should be implemented (this class is using the Spring methods for reflection). For writing to the field the ElasticsearchPersisntentProperty for that field should be used.

ad 2: this is an old (ugly) implementation to index an object and is only used in test scope. This could be refactored to something that does not use the reflection. But this is not relevant to native code, as it's only in the test

@sothawo sothawo added the status: waiting-for-feedback We need additional information before we can continue label Dec 15, 2021
@AntonLGVS
Copy link
Contributor Author

Case 2: I don't know how you can do something with an entity without using reflaction. And you also said that in makes no sense because it is in the test scope.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Dec 16, 2021
sothawo pushed a commit that referenced this issue Dec 18, 2021
@sothawo sothawo added this to the 4.4 M1 (2021.2.0) milestone Dec 18, 2021
@sothawo sothawo added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-provided Feedback has been provided type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants