[ 
https://issues.apache.org/jira/browse/HDDS-17378?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ivan Andika updated HDDS-17378:
-------------------------------
    Description: 
DatanodeStateMachine "this" reference escapes during its construction. See the 
following implementation below
{code:java}
context = new StateContext(this.conf, DatanodeStates.getInitState(), this,
        threadNamePrefix);
{code}
and 
{code:java}
container = new OzoneContainer(hddsDatanodeService, this.datanodeDetails,
    conf, context, certClient, secretKeyClient, volumeChoosingPolicy);{code}
and

 
{code:java}
versionManager = new DatanodeVersionManager(storage, this);{code}
 

>From "Java Concurrency in Practice", this means the DatanodeStateMachine is 
>{_}not properly constructed{_}.

See the excerpt: "An object is in a predictable, consistent state only after 
its constructor returns, so publishing an object from within its constructor 
can publish an incompletely constructed object"

And the exact imperative "Do not allow the `this` reference to escape during 
construction"

This issue seems to cause the workaround of having constructionLock in 
DatanodeStateMachine (see HDDS-3116) although we need to investigate a possible 
chain of events that trigger the NPE.

The code structure can be improved to ensure safe publication.

 

  was:
DatanodeStateMachine "this" reference escapes during its construction. See the 
following implementation below
{code:java}
context = new StateContext(this.conf, DatanodeStates.getInitState(), this,
        threadNamePrefix);
{code}
and 
{code:java}
container = new OzoneContainer(hddsDatanodeService, this.datanodeDetails,
    conf, context, certClient, secretKeyClient, volumeChoosingPolicy);{code}
and

 
{code:java}
versionManager = new DatanodeVersionManager(storage, this);{code}
 

>From "Java Concurrency in Practice", this means the DatanodeStateMachine is 
>{_}not properly constructed{_}.

See the excerpt: "An object is in a predictable, consistent state only after 
its constructor returns, so publishing an object from within its constructor 
can publish an incompletely constructed object"

And the exact imperative "Do not allow the `this` reference to escape during 
construction"

This issue seems to cause the workaround of having constructionLock in 
DatanodeStateMachine (see HDDS-3116).

The code structure can be improved to ensure safe publication.

 


> DatanodeStateMachine is not properly constructed
> ------------------------------------------------
>
>                 Key: HDDS-17378
>                 URL: https://issues.apache.org/jira/browse/HDDS-17378
>             Project: Apache Ozone
>          Issue Type: Bug
>            Reporter: Ivan Andika
>            Assignee: Ivan Andika
>            Priority: Major
>
> DatanodeStateMachine "this" reference escapes during its construction. See 
> the following implementation below
> {code:java}
> context = new StateContext(this.conf, DatanodeStates.getInitState(), this,
>         threadNamePrefix);
> {code}
> and 
> {code:java}
> container = new OzoneContainer(hddsDatanodeService, this.datanodeDetails,
>     conf, context, certClient, secretKeyClient, volumeChoosingPolicy);{code}
> and
>  
> {code:java}
> versionManager = new DatanodeVersionManager(storage, this);{code}
>  
> From "Java Concurrency in Practice", this means the DatanodeStateMachine is 
> {_}not properly constructed{_}.
> See the excerpt: "An object is in a predictable, consistent state only after 
> its constructor returns, so publishing an object from within its constructor 
> can publish an incompletely constructed object"
> And the exact imperative "Do not allow the `this` reference to escape during 
> construction"
> This issue seems to cause the workaround of having constructionLock in 
> DatanodeStateMachine (see HDDS-3116) although we need to investigate a 
> possible chain of events that trigger the NPE.
> The code structure can be improved to ensure safe publication.
>  



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to