Skip to content

Overcomplicated singleton initialization #10

@Miha-x64

Description

@Miha-x64

private static volatile EmulateResponseManager client;
private int fakeErrorCount = 0;
public static EmulateResponseManager getInstance() {
if (client == null) {
synchronized (EmulateResponseManager.class) {
if (client == null) {
client = new EmulateResponseManager();
}
}
}
return client;
}

Can be easily replaced with simpler and faster

    private static final EmulateResponseManager client = new EmulateResponseManager();

    private int fakeErrorCount = 0;

    public static EmulateResponseManager getInstance() {
        return client;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions