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

mapEvictionPolicy config becomes null when use JSON file to configure PCF service #14086

hasancelik opened this issue Nov 8, 2018 · 3 comments


Copy link

@hasancelik hasancelik commented Nov 8, 2018

At the PCF side, we are using JSON file to start service(hazelcast instance). hazelcast-json-starter takes the json file, converts it into Config object then starts hazelcast instance. While we are investigating one of the customer tickets reports that eviction does not work on PCF env, we have realized that mapEvictionPolicy is null though evictionPolicy is already configured at JSON file. The expected behaviour is, if evictionPolicy is configured but mapEvictionPolicy is not, mapEvictionPolicy should be configured into value of evictionPolicy.

mapEvictionPolicy becomes null because it is set only by XMLConfigBuilder class and at the hazelcast-json-starter side, gson library uses reflection of Config class to create it from JSON file:

First me and @gurbuzali have tried to fix this issue at hazelcast-json-starter side:

  • We started with jackson library which maps the fields of a JSON object to fields in a Java object by matching the names of the JSON field to the getter and setter methods in the Java object as a default, but we encountered a lot errors.

  • Then we tried to convert the JSON file into XML then create Config object from it but JSON --> XML conversion is very problematic, we need to handle a lot of hazelcast-xml specific edge cases and we need to update our hazelcast-full.json.

As a result we have decided to this issue should be fixed at hazelcast side. One of the possible solution of this issue is, we can set value of mapEvictionPolicy at own getter ,not at setEvictionPolicy() thus it will not become null:

Copy link

@ahmetmircik ahmetmircik commented Nov 8, 2018

gson library uses reflection of Config class to create it from JSON

Reflective access can break MapConfig internal implementations and it is not supported(i believe one can break other configs with it too). Only supported ways of creating a MapConfig object are programmatic or declarative(via XML) ways. We should go with a supported way to fix this issue for now and to prevent similar ones in the future.

Copy link
Contributor Author

@hasancelik hasancelik commented Nov 9, 2018

@ahmetmircik As i mentioned above, we have tried to fix this problem at json-starter repo to prevent future similar issues but we encountered a lot blocker issues/errors. As an radical solution for these kind of issues, we need a create separate JSONConfigBuilder at hazelcast side.

Copy link
Contributor Author

@hasancelik hasancelik commented Nov 20, 2018

I have created new PCF tile with current snapshot(3.12-SS) and tested @gurbuzali's fix at PCF environment, eviction mechanism worked properly.

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

Successfully merging a pull request may close this issue.

4 participants