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

Instantiating custom LoggerFactory two times #5641

Closed
dbatyuk opened this issue Jul 1, 2015 · 1 comment
Closed

Instantiating custom LoggerFactory two times #5641

dbatyuk opened this issue Jul 1, 2015 · 1 comment
Assignees
Milestone

Comments

@dbatyuk
Copy link

@dbatyuk dbatyuk commented Jul 1, 2015

Hi,

I am using hazelcast 3.4.1 and I implement custom LoggerFactory. While starting application it creates custom LoggerFactory two times if you are using XmlConfigBuilder for example. XmlConfigBuilder has LoggerFactory.getLogger(...) which creates custom LoggerFactory first time as it doesn't exist yet. Second time it is created when Hazelcast.newHazelcastInstance -> Node.init -> LoggingServiceImpl.init is called as it need to instantiate for application and it doesn't know that it exists already.

I think it would be better to prepare some singleton solution in LoggerFactory interface and stop using public constructor. Attaching stack traces of creating those two instances.

firstinstance
secondinstance

Thank you

@gurbuzali gurbuzali added the Team: Core label Jul 1, 2015
@gurbuzali gurbuzali added this to the 3.6 milestone Jul 1, 2015
@mdogan mdogan removed this from the 3.6 milestone Nov 2, 2015
@mmedenjak
Copy link
Contributor

@mmedenjak mmedenjak commented Jul 13, 2017

Still present in 3.8 - there are several calls to com.hazelcast.logging.Logger#newLoggerFactory, some of which are synchronized with a lock, some of which are not. This can lead to two factories being created.

@mmedenjak mmedenjak added this to the 3.9 milestone Jul 13, 2017
@jerrinot jerrinot modified the milestones: 3.10, 3.9 Jul 21, 2017
@mmedenjak mmedenjak added the To Triage label Oct 31, 2017
@taburet taburet self-assigned this Dec 28, 2017
taburet added a commit to taburet/hazelcast that referenced this issue Dec 29, 2017
taburet added a commit to taburet/hazelcast that referenced this issue Jan 22, 2018
@taburet taburet added Team: Core and removed Team: Core labels Jan 22, 2018
@mmedenjak mmedenjak removed the To Triage label Jan 29, 2018
taburet added a commit to taburet/hazelcast that referenced this issue Feb 15, 2018
taburet added a commit to taburet/hazelcast that referenced this issue Feb 19, 2018
This change brings following:

1. Eliminates the chance of creating `hazelcast.logging.class` factory
twice by doing the creation under the lock.

2. Improves the sharing of the static logger factory instance with
`LoggingService`s. If the type of the the static logger factory matches
with the type requested during the logging service construction, the
service will receive the shared logger factory instance.

3. Fixes the issue with the shared factory get set while invoking
`getLogger` when there is no `hazelcast.logging.type` setting provided.

4. Adds test cases to verify the expected behavior.

Fixes: hazelcast#5641
taburet added a commit that referenced this issue Mar 14, 2018
This change brings following:

1. Eliminates the chance of creating `hazelcast.logging.class` factory
twice by doing the creation under the lock.

2. Improves the sharing of the static logger factory instance with
`LoggingService`s. If the type of the the static logger factory matches
with the type requested during the logging service construction, the
service will receive the shared logger factory instance.

3. Fixes the issue with the shared factory get set while invoking
`getLogger` when there is no `hazelcast.logging.type` setting provided.

4. Adds test cases to verify the expected behavior.

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

Successfully merging a pull request may close this issue.

6 participants