Auto logout on Garbage Collection

This commit is contained in:
Timo Ley 2020-01-25 15:41:13 +01:00
parent 3fd31fcbd8
commit fe134a4172
1 changed files with 8 additions and 0 deletions

View File

@ -78,11 +78,19 @@ public class UntisClient {
public void logout() throws APIRequestException {
try {
client.invoke("logout", new Object[0], Object.class);
auth = null;
} catch (Throwable e) {
throw new APIRequestException(e);
}
}
@Override
protected void finalize() throws Throwable {
if (auth != null) {
logout();
}
}
/**
* Get list of subjects
* @return an ArrayList of subjects