[ https://issues.apache.org/jira/browse/GEODE-8512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17210984#comment-17210984 ]
ASF GitHub Bot commented on GEODE-8512: --------------------------------------- gaussianrecurrence commented on a change in pull request #661: URL: https://github.com/apache/geode-native/pull/661#discussion_r501818944 ########## File path: cppcache/integration/test/PdxJsonTypeTest.cpp ########## @@ -68,6 +68,32 @@ std::shared_ptr<Region> setupRegion(Cache& cache) { return region; } +TEST(PdxJsonTypeTest, testGfshQueryJsonInstances) { + Cluster cluster{LocatorCount{1}, ServerCount{1}}; + cluster.start(); + + auto& gfsh = cluster.getGfsh(); + gfsh.create().region().withName("region").withType("REPLICATE").execute(); + + auto cache = cluster.createCache(); + auto region = setupRegion(cache); + const std::string query_stmt{"SELECT * FROM /region"}; + + region->put("non-java-domain-class-entry", + cache.createPdxInstanceFactory(gemfireJsonClassName, false) + .writeString("foo", "bar") + .create()); + + EXPECT_NO_THROW(gfsh.query(query_stmt).execute()); + + region->put("java-domain-class-entry", + cache.createPdxInstanceFactory(gemfireJsonClassName) + .writeString("foo", "bar") + .create()); + + EXPECT_THROW(gfsh.query(query_stmt).execute(), GfshExecuteException); Review comment: Hi @mmartell, I think there's a singularity in the code. And with this I mean that it seems with those entries this test shows that code fails in failing. TBH I don't have a clue about what's happenning, I've tried changing the entries I write and these are the results: 1. **FAILED**: [1st: non-java-domain-class-entry => {foo: bar}; 2nd: java-domain-class-entry => {foo: bar}] 2. **PASSED**: [1st: non-java-domain-class-entry => {foo: bar}; 2nd: java-domain-class-entry => {foo2: bar}] 3. **PASSED**: [1st: non-java-domain-class-entry => {foo: bar}; 2nd: java-domain-class-entry => {foo: bar2}] 4. **FAILED**: [1st: non-java-domain-class-entry => {foo: bar}; 2nd: non-java-domain-class-entry => {foo: bar}] 5. **FAILED**: [1st: non-java-domain-class-entry => {foo: bar}; 2nd: non-java-domain-class-entry => {foo2: bar}] 6. **PASSED**: [1st: entry-1 => {entryName: entry-1}; 2nd: entry-2 => {entryName: entry-2}] 7. **PASSED**: [1st: entry-1 => {entryName: entry-1}; 2nd: entry-2 => {entryName: entry-1}] Cases **4 and 5** would somehow make sense to me, but should not be happenning as the PdxType should be different. But the f... up cases are **1 and 7** as they are equivalent but still 1 fails and 7 not. If you have any idea about what could be happening, I'd appreciate your ideas. My feeling here is that there are some issues with hashing functions either on the client or on the server, or even maybe in both. That's the only explanation for case 1 failing and 7 not as of my understanding. Anyhow, will keep digging on this matter :S ########## File path: cppcache/integration/test/PdxJsonTypeTest.cpp ########## @@ -68,6 +68,32 @@ std::shared_ptr<Region> setupRegion(Cache& cache) { return region; } +TEST(PdxJsonTypeTest, testGfshQueryJsonInstances) { + Cluster cluster{LocatorCount{1}, ServerCount{1}}; + cluster.start(); + + auto& gfsh = cluster.getGfsh(); + gfsh.create().region().withName("region").withType("REPLICATE").execute(); + + auto cache = cluster.createCache(); + auto region = setupRegion(cache); + const std::string query_stmt{"SELECT * FROM /region"}; + + region->put("non-java-domain-class-entry", + cache.createPdxInstanceFactory(gemfireJsonClassName, false) + .writeString("foo", "bar") + .create()); + + EXPECT_NO_THROW(gfsh.query(query_stmt).execute()); + + region->put("java-domain-class-entry", + cache.createPdxInstanceFactory(gemfireJsonClassName) + .writeString("foo", "bar") + .create()); + + EXPECT_THROW(gfsh.query(query_stmt).execute(), GfshExecuteException); Review comment: Ok, so I've been going throught the query engine code of the server and finally located the problem. As I feared org.apache.geode.cache.query.internal.Bag addAndGetOccurence method uses mapGet on the different objects added, and PdxInstanceImpl hash is not considering noJavaDomainClass attribute and neither is the equals operator therefore all PdxInstanceImpl with the same hash that are equals as of equals operator are not added but instead the previous existing copy inside bag is duplicated. Now the question, and here is where I need your help, is: "Is this a bug or a feature?" Because as of my point of view is a bug, but there might be many more implications than the one I am able to see. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Be able to specify 'expectDomainClass' when calling createPdxInstanceFactory > ---------------------------------------------------------------------------- > > Key: GEODE-8512 > URL: https://issues.apache.org/jira/browse/GEODE-8512 > Project: Geode > Issue Type: Improvement > Components: native client > Affects Versions: 1.13.0 > Reporter: Mario Salazar de Torres > Assignee: Mario Salazar de Torres > Priority: Minor > Labels: JsonFormatter, pull-request-available > > Within Java client, you can specify if the PdxInstance you want to create is > a Java domain class or not, but this is not the case for geode-native C++ > client. > Thing is that in order to implement JsonFormatter in C++ client, having this > change is mandatory, otherwise creating PdxType's with __GEMFIRE_JSON > classname will present some issues while using cquery's. > -- This message was sent by Atlassian Jira (v8.3.4#803005)