eclipse-ee4j / eclipse-ee4j/jersey

Missing replacement for ServiceLocator.postConstruct(Object)

Open
#3,924 0 comments 0 reactions 0 assignees View on GitHub
2.29 injection
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

Attempting to upgrade from Jersey 2.25.1 to 2.27, I am unable to convert the code:

```java
public T provide()
{
T object = supplier.get();
ServiceLocator locator = locatorReference.get();
locator.inject(object);
locator.postConstruct(object);
return object;
}
```

As `InjectionManager` does not have a `postConstruct(Object)` method and `AbstractHk2InjectionManager.inject(Object)` does not call `getServiceLocator().postConstruct(injectMe)`.

I believe there should be an `InjectionManager.postConstruct(Object)` method as the `createAndInitialize(Class)` method is documented as doing post-construction, there is an `InjectionManager.preDestroy(Object)` method, and it is conceivable the caller could want to mutate the object between injection and post-construction.

Contributor guide

Open the contributing guide

Research direction

Start by comparing the ServiceLocator.postConstruct(Object) usage with InjectionManager.inject(Object), createAndInitialize(Class), and preDestroy(Object). Check AbstractHk2InjectionManager.inject(Object) and the existing InjectionManager API to determine the intended lifecycle behavior. Done means callers can perform injection and post-construction separately without relying on the removed ServiceLocator method.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.