eclipse-ee4j / eclipse-ee4j/yasson

Components (adapters, de- serializes) not really cached because of the bug in the ComponentMatcher

Open
#627 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
218
Forks
109
Avg merge
1d 5h
Merged PRs (30d)
9

Description

**Describe the bug**
Because of the bug in the introspectXXX methods of the ComponentMatcher, the component's cache isn't really used. Because of this, a new instance is created every time.

**To Reproduce**
The bug: the class of the component is compared to the class of the binding from the cache, not to the class of the component inside the binding. The first equals is always false; therefore, the instance from the binding is never returned. Instead, a new instance is created or returned.

IntelliJ even warns here because both instances are inherited from the different classes, so there is no chance for this to be true.

**Expected behavior**
If the component was already registered for the given type, the old registered instance should be reused, not the new or created one.

**System information:**
- OS: Linux
- Java Version: 11
- Yasson Version: 3.0.3

**Additional context**
I will create a patch for this. Also, the only tests that could have more than one component on the type, the Number tests, will be extended to check that only one instance was created. This way, we can assert that the cache was used.

Contributor guide

Open the contributing guide

Research direction

Start with the ComponentMatcher introspectXXX methods and inspect how the cached binding's component is compared. Review the Number tests mentioned in the issue, then verify that repeated registration for a type reuses one component instance and that the tests assert this behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.