Skip to content

Handle top-level collections without entity lookup in MappingRedisConverter #2168 #3146

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Leehyoungwoo
Copy link

@Leehyoungwoo Leehyoungwoo commented May 9, 2025

Fix. #2168

Summary

This issue arises in MappingRedisConverter.write(…), which by default treats all inputs—including JDK internal types like Arrays.asList(...)—as domain entities. It looks up a PersistentEntity for every input and then retrieves metadata (keyspace, identifier, TTL). On Java 9+ this leads to an InaccessibleObjectException when reflection tries to access the non-exported constructor of Arrays$ArrayList.

To address this, I added an early check in write(...):

if (source instanceof Collection) {
    writeCollection(
        sink.getKeyspace(),
        "",
        (List<?>) source,
        TypeInformation.of(Object.class),
        sink
    );
    return;
}

This skips all metadata lookups for top-level collections by directly invoking writeCollection(...).

I removed the @EnabledOnJre(JRE.JAVA_8) restriction on the writePlainList() test (now annotated // GH-2168) and verified that it passes on non–Java 8 environments.

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 9, 2025
@Leehyoungwoo Leehyoungwoo force-pushed the feature/skip-collection-entity branch from 99b8acd to 43c473c Compare May 9, 2025 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants