Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ArrayList .equals() method with == to compare the objects #447

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ahmadov
Copy link
Contributor

@ahmadov ahmadov commented Jan 18, 2019

MemoryManagerReferenceHandler.v8HandleDisposed method is already
implemented with Iterator to compare the object using == instead of
.equals. Therefore,
MemoryManagerReferenceHandler.v8HandleDisposed can be used rather than
ArrayList.remove to remove object from references array.

Fix #444

MemoryManagerReferenceHandler.v8HandleDisposed method is already
implemented with Iterator to compare the object using `==` instead of
`.equals`. Therefore,
MemoryManagerReferenceHandler.v8HandleDisposed can be used rather than
ArrayList.remove to remove object from references array.

Fix #444
Copy link
Member

@irbull irbull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a few small comments. I wonder if you can add a test case for this.

@@ -92,7 +92,7 @@ public boolean isReleased() {
*/
public void release() {
v8.getLocker().checkThread();
if (released) {
if (isReleased()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change this as part of this commit. We can use the field without the accessor for internal calls.

@@ -109,7 +109,7 @@ public void release() {
}

private void checkReleased() {
if (released) {
if (isReleased()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. See above

@@ -73,7 +73,7 @@ public int getObjectReferenceCount() {
public void persist(final V8Value object) {
v8.getLocker().checkThread();
checkReleased();
references.remove(object);
memoryManagerReferenceHandler.v8HandleDisposed(object);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you include a test case in the MemoryManagerTest that gets the same V8ObjectTwice (so there are two copies of it) and then one is persisted? After we release the MemoryManager one should still remain. I can help you with this if you need help.

Unit tests verify the following cases:
* Persisted object decrease MemoryManager object reference count
* Duplicated object is not managed by MemoryManager when persisted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants