logback-kafka-appender icon indicating copy to clipboard operation
logback-kafka-appender copied to clipboard

Typo

Open leotu opened this issue 5 years ago • 1 comments

The error message "Hostname could not be found in context. HostNamePartitioningStrategy will not work." and variable name "hostname" are weird.

ContextNameKeyingStrategy: <-- problem code

@Override
    public void setContext(Context context) {
        super.setContext(context);
        final String hostname = context.getProperty(CoreConstants.CONTEXT_NAME_KEY);
        if (hostname == null) {
            addError("Hostname could not be found in context. HostNamePartitioningStrategy will not work.");
        } else {
            contextNameHash = ByteBuffer.allocate(4).putInt(hostname.hashCode()).array();
        }
    }

HostNameKeyingStrategy:

 @Override
    public void setContext(Context context) {
        super.setContext(context);
        final String hostname = context.getProperty(CoreConstants.HOSTNAME_KEY);
        if (hostname == null) {
            if (!errorWasShown) {
            addError("Hostname could not be found in context. HostNamePartitioningStrategy will not work.");
                errorWasShown = true;
            }
        } else {
            hostnameHash = ByteBuffer.allocate(4).putInt(hostname.hashCode()).array();
        }
    }

leotu avatar Mar 15 '19 07:03 leotu

Good catch, thanks! Tribute to the copy & paste error god 😊

danielwegener avatar Mar 15 '19 10:03 danielwegener