eclipse-ee4j / eclipse-ee4j/jersey

RequestScoped objects destroyed in wrong order

Open
#3,503 5 comments 2 reactions 0 assignees View on GitHub
Component: core Priority: Blocker Type: Bug
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

Objects created by RequestScoped Factories can be disposed after the Factory itself, causing the creation of a new factory to dispose the object.

```
Bad Case:
ObjectFactory instance created
Object instance created from factory
.....
Execution of Resource endpoint
.....
ObjectFactory instance disposed
....
Object instance dispose will need a new ObjectFactory created to call dispose on it.
ObjectFactory second instance is disposed
```
```
Expected Case:
ObjectFactory instance created
Object instance created from factory
.....
Execution of Resource endpoint
.....
Object instance disposed by calling ObjectFactory.dispose method.
ObjectFactory instance disposed
```

Objects should disposed in reverse order from creation. I created a gist with the needed changes to RequestScope.Instance class. Only the modified methods are part of the gist.
#### Environment
jdk1.8.0_111
Mac OSX 10.11.6
#### Affected Versions
[3.0, 2.25.1]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.