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

ORecordLazyList.get(index) started to return ORecordId instead of ODocument #9421

Closed
PhantomYdn opened this issue Oct 26, 2020 · 6 comments
Closed

Comments

@PhantomYdn
Copy link
Contributor

OrientDB Version: 3.1.4

Java Version: 8

OS: Windows, Linux

Some of our tests started to fail after switching from 3.1.3 to 3.1.4 due to ClassCastException.
After review we have figured out that problem is in ORecordLazyList: first item is ODocument, but all subsequent are just ORecordId (but a corresponding ODocument does exist)

Expected behavior

ORecordLazyList should return ODocument

Actual behavior

All items after first one are ORecordId

Steps to reproduce

Not fully sure how to reproduce from scratch. The following our testcase stopped working: https://github.com/OrienteerBAP/Orienteer/blob/future/orienteer-notification/src/test/java/org/orienteer/notifications/test/TestNotificationLifecycle.java

@PhantomYdn
Copy link
Contributor Author

@tglman git bisect between 3.1.3 and 3.1.4 show that the issue was introduced by the following commit: 6265642

@PhantomYdn
Copy link
Contributor Author

@tglman, @Laa, @luigidellaquila, OrientDB team, do you have ideas how to fix that? 3.1.4 is unusable due to this issue...

@PhantomYdn
Copy link
Contributor Author

Apparently, the reason is in fact that mentioned above commit doesn't affect logic of iterator(). Defect is pretty visible in the following testcase:

@Test
public void testLinkListAndODocumentConversion()
{
	ODatabaseSession db = wicket.getTester().getDatabaseSession();
	OSchemaHelper helper = OSchemaHelper.bind(db);
	helper.oClass("TestODocumentConverstion")
			.oProperty("name", OType.STRING)
			.oProperty("items", OType.LINKLIST);
	ODocument mainDoc = helper.oDocument("name", "document").saveDocument().getODocument();
	helper.oClass("TestODocumentConverstionItems")
		  	.oProperty("name", OType.STRING);
	ODocument doc1 = helper.oDocument("name", "item1").saveDocument().getODocument();
	ODocument doc2 = helper.oDocument("name", "item2").saveDocument().getODocument();
	ODocument doc3 = helper.oDocument("name", "item3").saveDocument().getODocument();
	List<ODocument> items = Arrays.asList(doc1, doc2, doc3);
	mainDoc.field("items", items);
	mainDoc.save();
	db.commit();
	db.begin();
	mainDoc = (ODocument)mainDoc.reload();
	items = mainDoc.field("items", List.class);
	items.iterator().next(); // IMPORTANT LINE
	assertTrue(items.get(0) instanceof ODocument);
	assertEquals(doc1, items.get(0));
	assertTrue(items.get(1) instanceof ODocument);
	assertEquals(doc2, items.get(1));
	assertTrue(items.get(2) instanceof ODocument);
	assertEquals(doc3, items.get(2));
	db.commit();
}

This test-case will fail, but if you comment out line marked as IMPORTANT LINE - test-case will be OK

@PhantomYdn
Copy link
Contributor Author

Investigation shown that HelperClasses.readLinkCollection() should be able to adjust ORecordLazyList.contentType. Otherwise: during iterating method OLazyRecordIterator.next() invokes update() which switch ORecordLazyList.contentType from EMPTY to ALL_RECORDS

@PhantomYdn
Copy link
Contributor Author

PhantomYdn commented Nov 12, 2020

Issue was fixed by PR #9437
Please merge

@PhantomYdn
Copy link
Contributor Author

Issue can be closed, because corresponding PR was merged. Thank you, @tglman !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant