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

refactor: don't block when polling ircCommandQueue #544

Merged
merged 1 commit into from Mar 8, 2022

Conversation

iProdigy
Copy link
Member

@iProdigy iProdigy commented Mar 4, 2022

Prerequisites for Code Changes

  • This pull request follows the code style of the project
  • I have tested this feature

Issues Fixed

Avoids the following exception from being logged on ITwitchClient#close:

[ERROR] c.g.t.chat.TwitchChat - Chat: Unexpected error in worker thread
java.lang.InterruptedException: null
	at java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1668)
	at java.base/java.util.concurrent.ArrayBlockingQueue.poll(ArrayBlockingQueue.java:435)
	at com.github.twitch4j.chat.TwitchChat.lambda$new$0(TwitchChat.java:349)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
	at java.base/java.lang.Thread.run(Thread.java:832)

(the thread still shuts down gracefully, just the exception can appear spooky for a normal operation)

Changes Proposed

  • Do not block when polling ircCommandQueue for an element (so no more InterruptedException would be fired)

Additional Information

flushCommand is called frequently enough that the blocking poll is not needed

 

Thanks to 쩌리곰#3393 for reporting

@iProdigy iProdigy merged commit ea9f339 into develop Mar 8, 2022
@iProdigy iProdigy deleted the refactor/chat-block-queue-poll branch March 8, 2022 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants