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

Conflict with Spring cloud SpringApplication run #84

Open
hmc1986 opened this issue Mar 8, 2019 · 0 comments
Open

Conflict with Spring cloud SpringApplication run #84

hmc1986 opened this issue Mar 8, 2019 · 0 comments

Comments

@hmc1986
Copy link

hmc1986 commented Mar 8, 2019

Conflict with Spring cloud SpringApplication run. spring cloud because BootstrapApplicationListener.Causes Spring Application to execute many times.
and call FluentLogger stop. close sender, with sender is null.
then call log(String tag, Map<String, Object> data, long timestamp) function Throw out NullPointerException?
in FluentLoggerFactory 58 line add this code?

public synchronized FluentLogger getLogger(String tagPrefix, String host, int port, int timeout, int bufferCapacity,
            Reconnector reconnector) {
        String key = String.format("%s_%s_%d_%d_%d", new Object[] { tagPrefix, host, port, timeout, bufferCapacity });

        for (Map.Entry<FluentLogger, String> entry : loggers.entrySet()) {
            if (entry.getValue().equals(key)) {
                FluentLogger found = entry.getKey();
                if(found != null) {
                    if(found.getSender() == null){
                        found.setSender(getNewSender(host, port, timeout, bufferCapacity, reconnector));
                    }
                    return found;
                }
                break;
            }
        }


        FluentLogger logger = new FluentLogger(tagPrefix, getNewSender(host, port, timeout, bufferCapacity, reconnector));
        loggers.put(logger, key);
        return logger;
    }

private Sender getNewSender( String host, int port, int timeout, int bufferCapacity, Reconnector reconnector){
        Sender sender = null;
        Properties props = System.getProperties();
        if (!props.containsKey(Config.FLUENT_SENDER_CLASS)) {
            // create default sender object
            sender = new RawSocketSender(host, port, timeout, bufferCapacity, reconnector);
        } else {
            String senderClassName = props.getProperty(Config.FLUENT_SENDER_CLASS);
            try {
                sender = createSenderInstance(senderClassName, new Object[] { host, port, timeout, bufferCapacity });
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return sender;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant