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

Closing httpclient properly on logback shutdown #112

Merged
merged 2 commits into from
Mar 28, 2019

Conversation

SuramVishal
Copy link
Contributor

Code at present only closes httpclient, if eventsBatch.size() > 0.

But there might be scenarios where logback calls shutdown and there are no events to flush. Therefore sender.stopHttpClient() never being called preventing a main method exit due to non-deamon thread usage of httpClient.

Code at present only closes httpclient, if `eventsBatch.size() > 0`.
But there might be scenarios where logback calls shutdown and there are no events to flush. Therefore `sender.stopHttpClient()` never being called preventing a main method exit due to non-deamon thread usage of httpClient.
@shakeelmohamed
Copy link
Contributor

@SuramVishal This change seems fine. Have you verified that it addresses your issue?

Please fix the indents so it matches the rest of the file.

@SuramVishal
Copy link
Contributor Author

SuramVishal commented Mar 16, 2019

@shakeelmohamed Yes, I have tested this and it does address my issue. Would you be able to make this a part of a new release (potentially 1.7.2) now? Would be really helpful, so that we can use this in our work. Thanks for the swift review by the way.

@SuramVishal
Copy link
Contributor Author

Hi @shakeelmohamed any help? :)

@shakeelmohamed
Copy link
Contributor

@SuramVishal do you have some steps to reproduce the issue?
It's great to hear you've got your issue fixed, we just want to verify it on our end and potentially write a test for this scenario.

This will definitely be in the next release, I'm not exactly sure when that will be though.

@shakeelmohamed shakeelmohamed changed the base branch from master to develop March 20, 2019 18:07
@SuramVishal
Copy link
Contributor Author

Okay to reproduce:

public class Application {

    public static void main(String[] args) {
        final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(Application.class);
        log.info("Hello World!");
    }
}

with logback appender as

    <appender name="SPLUNK" class="com.splunk.logging.HttpEventCollectorLogbackAppender">
        <url>${SPLUNK_URL}</url>
        <index>${SPLUNK_INDEX}</index>
        <source>${SPLUNK_SOURCE}</source>
        <sourcetype>${SPLUNK_SOURCE_TYPE}</sourcetype>
        <token>${SPLUNK_TOKEN}</token>
        <disableCertificateValidation>true</disableCertificateValidation>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%msg</pattern>
        </layout>
        <messageFormat>json</messageFormat>
    </appender>

@SuramVishal
Copy link
Contributor Author

SuramVishal commented Mar 25, 2019

@shakeelmohamed It would be really helpful if you can help prioritise this issue. This is major when it comes to all short living applications using splunk appender. :) Please do let me know if you need any further details.

@fantavlik
Copy link
Contributor

Hey @SuramVishal thanks for the testcase, I'm going to try to reproduce this today and hopefully get this merged. Thanks for your help!

@SuramVishal
Copy link
Contributor Author

@fantavlik, much appreciated. Please let me know if you have any difficulties in reproducing. :)

@fantavlik
Copy link
Contributor

Apologies, I ran into issues setting up my environment. I've been able to repro the fact that the httpClient is not closed for your setup. Thanks for your contribution and we will get this into the next release.

@fantavlik fantavlik merged commit 9ac27f3 into splunk:develop Mar 28, 2019
@SuramVishal
Copy link
Contributor Author

Thank you @fantavlik , @shakeelmohamed for reviewing the PR. May I kindly know when the next release would be? Can we get it asap? So that we can continue to use the library in our work. :)

@fantavlik
Copy link
Contributor

I'm cutting a 1.7.2 release today! 🎉

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

Successfully merging this pull request may close these issues.

3 participants