[ 
https://issues.apache.org/jira/browse/OPENJPA-2958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18110762#comment-18110762
 ] 

ASF subversion and git services commented on OPENJPA-2958:
----------------------------------------------------------

Commit a1e3c275dd2ce1ffc5ae8438a249606379567dbb in openjpa's branch 
refs/heads/master from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=a1e3c275d ]

[OPENJPA-2958] Add ImplHelper.registerUnenhancedInstance() (#170)

* [OPENJPA-2958] Add ImplHelper.registerUnenhancedInstance()

BrokerImpl reached into the public mutable ImplHelper._unenhancedInstanceMap
to register the persistence capable instance of an unenhanced one. Add a
method for it and route all three write sites through it, so the registry
is no longer written to from outside the class that owns it. Behaviour is
unchanged: the method is the same overwriting put.

The field is deprecated to point callers at the method. It stays public:
its type is a reference type, so it is never inlined into callers, and
making it private would turn into a NoSuchFieldError at runtime for
anything compiled against 4.1.x rather than a compile error on upgrade.
Making it private belongs in a major release.

* [OPENJPA-2958] Make the unenhanced instance registry package private

Review feedback: 4.2.0 already removes public API, so keeping the field
public for compatibility was not worth it. Nothing outside ImplHelper reads
or writes it any more. Package private rather than private so that the unit
test, which lives in the same package, can still read a registration back;
there is no public read path for it, since toPersistenceCapable() rejects a
non manageable instance before it reaches the map.

> Direct access to ImplHelper._unenhancedInstanceMap
> --------------------------------------------------
>
>                 Key: OPENJPA-2958
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2958
>             Project: OpenJPA
>          Issue Type: Sub-task
>          Components: jpa
>    Affects Versions: 4.2.0
>            Reporter: Maxim Solodovnik
>            Assignee: Richard Zowalla
>            Priority: Major
>             Fix For: 4.2.0
>
>
> Discussion thread: 
> https://github.com/apache/openjpa/pull/144#discussion_r3683000504
> **(low)** Reaching into `ImplHelper._unenhancedInstanceMap` (a public mutable 
> static field) directly is fragile - suggest a small 
> `ImplHelper.registerUnenhancedInstance(obj, pc)` method instead of exposing 
> the raw map.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to