greenrobot/greenDAO · error · DaoException
Interrupted while waiting for operation to complete
Error message
Interrupted while waiting for operation to complete
What it means
The blocking AsyncOperation.waitForCompletion() waits on the operation's monitor until the async executor marks it completed. If the waiting thread is interrupted while blocked in wait(), greendao converts the InterruptedException into a DaoException so the interrupted-wait cannot be silently ignored.
Solutions
- Do not interrupt threads that are blocked on async DAO completion; check your thread pool / AsyncTask shutdown logic.
- Catch DaoException and restore the interrupt flag (Thread.currentThread().interrupt()) so cancellation semantics are preserved.
- Prefer the non-blocking AsyncOperationListener onOperationCompleted callback over blocking waits.
- Use waitForCompletion(int maxMillis) with a timeout if indefinite blocking is undesirable.
Example fix
// before
Object result = asyncSession.insert(entity).getResult();
// after
try {
Object result = asyncSession.insert(entity).getResult();
} catch (DaoException e) {
Thread.currentThread().interrupt();
Log.w(TAG, "interrupted waiting for async op", e);
} Defensive patterns
Strategy: try-catch
Try / catch
try {
Object result = op.getResult();
} catch (DaoException e) {
Thread.currentThread().interrupt(); // restore interrupt status
return null;
} Prevention
- Avoid blocking waits on threads that get interrupted (AsyncTask, shutdownNow)
- Prefer AsyncOperationListener callbacks over getResult()/waitForCompletion()
- Restore the interrupt flag when catching this DaoException
When it happens
Trigger: Calling getResult() (or waitForCompletion()) on an AsyncOperation whose thread gets interrupted — e.g. the enclosing worker/executor thread is shut down, an Activity timeout cancels the thread, or another thread calls interrupt() on it.
Common situations: Blocking on async DAO results inside Android worker threads that are interrupted during app teardown, ExecutorService.shutdownNow(), or AsyncTask cancellation.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
Related errors
- Interrupted while waiting for all operations to complete
- Internal error: peeked op did not match removed op
- This operation did not yet complete
- Unsupported operation
- Method may be called only in owner thread, use…
AI-assisted analysis of greenrobot/greenDAO@0bbb338e17 (2026-09-08).
Data as JSON: /api/errors/30476d67241ba2de.
Report an issue: GitHub.
Appendix: source
Thrown at DaoCore/src/main/java/org/greenrobot/greendao/async/AsyncOperation.java:162
return throwable != null;
}
public boolean isCompleted() {
return completed;
}
/**
* Waits until the operation is complete. If the thread gets interrupted, any {@link InterruptedException} will be
* rethrown as a {@link DaoException}.
*
* @return Result if any, see {@link #getResult()}
*/
public synchronized Object waitForCompletion() {
while (!completed) {
try {
wait();
} catch (InterruptedException e) {
throw new DaoException("Interrupted while waiting for operation to complete", e);
}
}
return result;
}
/**
* Waits until the operation is complete, but at most the given amount of milliseconds.If the thread gets
* interrupted, any {@link InterruptedException} will be rethrown as a {@link DaoException}.
*
* @return true if the operation completed in the given time frame.
*/
public synchronized boolean waitForCompletion(int maxMillis) {
if (!completed) {
try {
wait(maxMillis);
} catch (InterruptedException e) {
throw new DaoException("Interrupted while waiting for operation to complete", e);
}View on GitHub (pinned to 0bbb338e17)