-
Notifications
You must be signed in to change notification settings - Fork 104
Add constant write backoff in GelfTCPSender for cases when a sender c… #249
Conversation
…annot write any bytes to the socket channel several times. Limit the time to stay in such mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for the first iteration. I left a few comments to address.
} catch (InterruptedException e) { | ||
Thread.currentThread().interrupt(); | ||
} | ||
long sleepTimeMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nano time is prone for overflows. Millis should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please share more details (maybe some link to the description) regarding this issue?
it is a common pattern of nanotime usage..
Regarding overflow I am aware only about this point:
https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#nanoTime--
Differences in successive calls that span greater than approximately 292 years (2^63 nanoseconds) will not correctly compute elapsed time due to numerical overflow.
System.currentTimeMillis() may have not enough precision in some cases.
src/main/java/biz/paluch/logging/gelf/intern/sender/DefaultGelfSenderProvider.java
Show resolved
Hide resolved
src/main/java/biz/paluch/logging/gelf/intern/sender/GelfTCPSender.java
Outdated
Show resolved
Hide resolved
…new parameters to docs, stop attempts to send a message in case of InterruptedException
for cases when a sender cannot write any bytes to the socket channel several times. Limit the time to stay in such mode. stop attempts to send a message in case of InterruptedException. Original pull request: #249
Thank you for your contribution. That's merged and polished now. |
Thank you a lot for the quick responses. |
1.14.1 is available from Maven Central. I decided to ship a release earlier this morning since the last one was shipped about 6 months ago. |
…annot write any bytes to the socket channel several times. Limit the time to stay in such mode.
fixes #248