Skip to content

Commit

Permalink
#933: Call onUnexpectedError() when unexpected error occurred
Browse files Browse the repository at this point in the history
If a task that are belong to `DefaultRegistrationEngine` raises
unexpected `RuntimeException` and the `observer` member variable
implements `LwM2mClientObserver2` (instead of `LwM2mClientObserver`),
it calls `LwM2mClientObserver2#onUnexpectedError()` hook.
The purpose of this hook gimmick is to shutdown the client application
mainly.

Signed-off-by: moznion <[email protected]>
  • Loading branch information
moznion authored and sbernard31 committed Dec 10, 2020
1 parent 9d5b405 commit b242989
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.eclipse.leshan.client.RegistrationUpdate;
import org.eclipse.leshan.client.bootstrap.BootstrapHandler;
import org.eclipse.leshan.client.observer.LwM2mClientObserver;
import org.eclipse.leshan.client.observer.LwM2mClientObserver2;
import org.eclipse.leshan.client.request.LwM2mRequestSender;
import org.eclipse.leshan.client.resource.LwM2mObjectEnabler;
import org.eclipse.leshan.client.resource.LwM2mObjectTree;
Expand Down Expand Up @@ -517,6 +518,9 @@ public void run() {
LOG.info("Bootstrap task interrupted. ");
} catch (RuntimeException e) {
LOG.error("Unexpected exception during bootstrap task", e);
if (observer instanceof LwM2mClientObserver2) {
((LwM2mClientObserver2) observer).onUnexpectedError(e);
}
}
}
}
Expand Down Expand Up @@ -555,6 +559,9 @@ public void run() {
LOG.info("Registration task interrupted. ");
} catch (RuntimeException e) {
LOG.error("Unexpected exception during registration task", e);
if (observer instanceof LwM2mClientObserver2) {
((LwM2mClientObserver2) observer).onUnexpectedError(e);
}
}
}
}
Expand Down Expand Up @@ -603,6 +610,9 @@ public void run() {
LOG.info("Registration update task interrupted.");
} catch (RuntimeException e) {
LOG.error("Unexpected exception during update registration task", e);
if (observer instanceof LwM2mClientObserver2) {
((LwM2mClientObserver2) observer).onUnexpectedError(e);
}
}
}
}
Expand Down

0 comments on commit b242989

Please sign in to comment.