{"action":"created","issue":{"url":"https://api.github.com/repos/hazelcast/hazelcast/issues/13512","repository_url":"https://api.github.com/repos/hazelcast/hazelcast","labels_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/13512/labels{/name}","comments_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/13512/comments","events_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/13512/events","html_url":"https://github.com/hazelcast/hazelcast/pull/13512","id":346203632,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA1MTI0OTU4","number":13512,"title":"Fix constructor cache in ClassLoaderUtil & typos","user":{"login":"viliam-durina","id":9109877,"node_id":"MDQ6VXNlcjkxMDk4Nzc=","avatar_url":"https://avatars0.githubusercontent.com/u/9109877?v=4","gravatar_id":"","url":"https://api.github.com/users/viliam-durina","html_url":"https://github.com/viliam-durina","followers_url":"https://api.github.com/users/viliam-durina/followers","following_url":"https://api.github.com/users/viliam-durina/following{/other_user}","gists_url":"https://api.github.com/users/viliam-durina/gists{/gist_id}","starred_url":"https://api.github.com/users/viliam-durina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/viliam-durina/subscriptions","organizations_url":"https://api.github.com/users/viliam-durina/orgs","repos_url":"https://api.github.com/users/viliam-durina/repos","events_url":"https://api.github.com/users/viliam-durina/events{/privacy}","received_events_url":"https://api.github.com/users/viliam-durina/received_events","type":"User","site_admin":false},"labels":[{"id":1036616751,"node_id":"MDU6TGFiZWwxMDM2NjE2NzUx","url":"https://api.github.com/repos/hazelcast/hazelcast/labels/Source:%20Jet","name":"Source: Jet","color":"3afc37","default":false},{"id":137752575,"node_id":"MDU6TGFiZWwxMzc3NTI1NzU=","url":"https://api.github.com/repos/hazelcast/hazelcast/labels/Team:%20Core","name":"Team: Core","color":"fef2c0","default":false},{"id":1740690,"node_id":"MDU6TGFiZWwxNzQwNjkw","url":"https://api.github.com/repos/hazelcast/hazelcast/labels/Type:%20Defect","name":"Type: Defect","color":"eb6420","default":false}],"state":"open","locked":false,"assignee":{"login":"viliam-durina","id":9109877,"node_id":"MDQ6VXNlcjkxMDk4Nzc=","avatar_url":"https://avatars0.githubusercontent.com/u/9109877?v=4","gravatar_id":"","url":"https://api.github.com/users/viliam-durina","html_url":"https://github.com/viliam-durina","followers_url":"https://api.github.com/users/viliam-durina/followers","following_url":"https://api.github.com/users/viliam-durina/following{/other_user}","gists_url":"https://api.github.com/users/viliam-durina/gists{/gist_id}","starred_url":"https://api.github.com/users/viliam-durina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/viliam-durina/subscriptions","organizations_url":"https://api.github.com/users/viliam-durina/orgs","repos_url":"https://api.github.com/users/viliam-durina/repos","events_url":"https://api.github.com/users/viliam-durina/events{/privacy}","received_events_url":"https://api.github.com/users/viliam-durina/received_events","type":"User","site_admin":false},"assignees":[{"login":"viliam-durina","id":9109877,"node_id":"MDQ6VXNlcjkxMDk4Nzc=","avatar_url":"https://avatars0.githubusercontent.com/u/9109877?v=4","gravatar_id":"","url":"https://api.github.com/users/viliam-durina","html_url":"https://github.com/viliam-durina","followers_url":"https://api.github.com/users/viliam-durina/followers","following_url":"https://api.github.com/users/viliam-durina/following{/other_user}","gists_url":"https://api.github.com/users/viliam-durina/gists{/gist_id}","starred_url":"https://api.github.com/users/viliam-durina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/viliam-durina/subscriptions","organizations_url":"https://api.github.com/users/viliam-durina/orgs","repos_url":"https://api.github.com/users/viliam-durina/repos","events_url":"https://api.github.com/users/viliam-durina/events{/privacy}","received_events_url":"https://api.github.com/users/viliam-durina/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/hazelcast/hazelcast/milestones/106","html_url":"https://github.com/hazelcast/hazelcast/milestone/106","labels_url":"https://api.github.com/repos/hazelcast/hazelcast/milestones/106/labels","id":2867560,"node_id":"MDk6TWlsZXN0b25lMjg2NzU2MA==","number":106,"title":"3.11","description":"","creator":{"login":"jerrinot","id":158619,"node_id":"MDQ6VXNlcjE1ODYxOQ==","avatar_url":"https://avatars1.githubusercontent.com/u/158619?v=4","gravatar_id":"","url":"https://api.github.com/users/jerrinot","html_url":"https://github.com/jerrinot","followers_url":"https://api.github.com/users/jerrinot/followers","following_url":"https://api.github.com/users/jerrinot/following{/other_user}","gists_url":"https://api.github.com/users/jerrinot/gists{/gist_id}","starred_url":"https://api.github.com/users/jerrinot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerrinot/subscriptions","organizations_url":"https://api.github.com/users/jerrinot/orgs","repos_url":"https://api.github.com/users/jerrinot/repos","events_url":"https://api.github.com/users/jerrinot/events{/privacy}","received_events_url":"https://api.github.com/users/jerrinot/received_events","type":"User","site_admin":false},"open_issues":149,"closed_issues":465,"state":"open","created_at":"2017-10-26T14:31:27Z","updated_at":"2018-08-28T13:42:14Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2018-07-31T14:06:17Z","updated_at":"2018-08-28T15:48:45Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/hazelcast/hazelcast/pulls/13512","html_url":"https://github.com/hazelcast/hazelcast/pull/13512","diff_url":"https://github.com/hazelcast/hazelcast/pull/13512.diff","patch_url":"https://github.com/hazelcast/hazelcast/pull/13512.patch"},"body":""},"comment":{"url":"https://api.github.com/repos/hazelcast/hazelcast/issues/comments/416638416","html_url":"https://github.com/hazelcast/hazelcast/pull/13512#issuecomment-416638416","issue_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/13512","id":416638416,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNjYzODQxNg==","user":{"login":"vbekiaris","id":1212378,"node_id":"MDQ6VXNlcjEyMTIzNzg=","avatar_url":"https://avatars0.githubusercontent.com/u/1212378?v=4","gravatar_id":"","url":"https://api.github.com/users/vbekiaris","html_url":"https://github.com/vbekiaris","followers_url":"https://api.github.com/users/vbekiaris/followers","following_url":"https://api.github.com/users/vbekiaris/following{/other_user}","gists_url":"https://api.github.com/users/vbekiaris/gists{/gist_id}","starred_url":"https://api.github.com/users/vbekiaris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vbekiaris/subscriptions","organizations_url":"https://api.github.com/users/vbekiaris/orgs","repos_url":"https://api.github.com/users/vbekiaris/repos","events_url":"https://api.github.com/users/vbekiaris/events{/privacy}","received_events_url":"https://api.github.com/users/vbekiaris/received_events","type":"User","site_admin":false},"created_at":"2018-08-28T15:48:45Z","updated_at":"2018-08-28T15:48:45Z","author_association":"CONTRIBUTOR","body":"Fixes #13509 \r\n\r\nFor the benefit of another reviewer and double-checking the original intent of this PR, here is my understanding of the changes in `ClassLoaderUtil.newInstance` (hoping it makes some sense):\r\n\r\n_Previous resolution scheme_\r\n\r\n1. If `classLoader` argument to `newInstance` is `null`, use `ClassLoaderUtil.classLoader` (using this as short for `ClassLoaderUtil.getClass().getClassLoader()`)\r\n2. Lookup in constructor cache with `classloader` given as argument / `ClassLoaderUtil.classLoader`\r\n3. if not found attempt to load class\r\n  - if primitive, load primitive class, return it\r\n  - attempt with given `classloader` argument to `loadClass` (can be original `classloader` argument to `newInstance` or `ClassLoaderUtil.classLoader` if that was `null`)\r\n  - attempt with `TCCL`\r\n  - if Hazelcast class, attempt with `ClassLoaderUtil.classLoader`\r\n  - try with `Class.forName` (this one seems a tautology with previous attempt to load via `ClassLoaderUtil.classLoader` since we are invoking `Class.forName` from `ClassLoaderUtil` - see [javadoc: \"where currentLoader denotes the defining class loader of the current class.\"](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#forName-java.lang.String-))\r\n4. Once `loadClass` has returned, if a class was found and a no-args declared constructor was found, cache it with the _`classloader` arg to `loadClass` as key even if other `ClassLoader` loaded the class_, construct a new instance and return it\r\n\r\n_With this PR's changes_\r\n\r\n1. if primitive class, load it, find no-arg declared constructor, creat new instance and return it. No caching of primitive class constructors (what could be the impact of this?).\r\n2. Identify 2 candidate `ClassLoader`s for loading the requested class:\r\n  - if `classloader` arg is null, then they will be `ClassLoaderUtil.classLoader` & `TCCL`\r\n  - if `classloader` arg is not null, then they will be `classloader` arg & `ClassLoaderUtil.classLoader` (if looking up a Hazelcast class) or `TCCL` (if non-HZ class)\r\n  - if `ClassLoaderUtil.classLoader` / `TCCL` is null (eg when running under Graal/SubstrateVM as native image), then `Class.forName` will be tried to load the class (as at least one of `cl1`/`cl2` will be `null`)\r\n3. Once loadClass has returned, if a class was found and a declaredConstructor was found, cache it with the classloader that loaded the class, construct new instance and return it.\r\n\r\n_Summary_\r\nI am for merging this PR once the caching of primitive class constructors is restored (or let's document whether we consider the impact of removing this caching is negligible)."}}
{"actor":{"display_login":"vbekiaris"}}