[
https://issues.apache.org/jira/browse/OPENJPA-2962?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18111055#comment-18111055
]
ASF subversion and git services commented on OPENJPA-2962:
----------------------------------------------------------
Commit e2ecff51f6c1c889bdce5a342ca3e1be698fce04 in openjpa's branch
refs/heads/master from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=e2ecff51f ]
[OPENJPA-2962] Do not create a broker to obtain a class loader
The four schema management methods each built a Broker through
newBrokerImpl() only to call getClassLoader() on it. That loader was always
null: BrokerImpl assigns it in initialize(), which newBrokerImpl() does not
reach, so the broker answered a question it could not answer and was then
dropped. They now pass the thread context class loader, which is the value
initialize() would have assigned and which postCreationCallback() already
passes for the same synchronizeMappings() calls.
Closing the broker instead was not an option: close() runs free(), which
dereferences a cache that an uninitialized broker has not got, so it throws.
Nothing heavyweight leaked, though, since without initialize() there is no
store manager, no connection and no registration with the factory; what the
call cost was a finalizable object per invocation whose finalizer threw and
was discarded.
The only behaviour that changes is that a class loader now reaches
MappingTool, so a custom openjpa.Sequence class resolves where it
previously fell back to the bootstrap loader.
The ticket also names dropPersistenceStrucuture and
validatePersistenceStruture; cbb19f777 has since corrected both spellings.
> Schema-gen methods leak a Broker just to get classloader
> --------------------------------------------------------
>
> Key: OPENJPA-2962
> URL: https://issues.apache.org/jira/browse/OPENJPA-2962
> Project: OpenJPA
> Issue Type: Sub-task
> Components: jpa
> Affects Versions: 4.2.0
> Reporter: Maxim Solodovnik
> Priority: Major
> Fix For: 4.2.0
>
>
> Discussion thread:
> https://github.com/apache/openjpa/pull/144#discussion_r3683001994
> **(medium)** `createPersistenceStructure`, `dropPersistenceStrucuture`,
> `validatePersistenceStruture` and `truncateData` each create a Broker via
> `super.newBrokerImpl(...)` that is only used for `getClassLoader()` and never
> closed - a broker (and its resources) leaked per call. Can the classloader be
> obtained without instantiating a broker?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)