Skip to content

Commit

Permalink
Fixed cache manager exceptions (im doing this while watching aot fina…
Browse files Browse the repository at this point in the history
…l season live omg such an amazing anime :33)
  • Loading branch information
bytedream committed Jan 16, 2022
1 parent ae4240b commit 30bab22
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/org/bytedream/untis4j/CacheManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,21 @@ public <T extends BaseResponse> T getOrRequest(UntisUtils.Method method, Request

Function<Integer, BaseResponse> function = (objects) -> {
try {
BaseResponse response = action.getResponse(requestManager.POST(method.getMethod(), params));
cachedInformation.put(keyHashCode, response);
return response;
return action.getResponse(requestManager.POST(method.getMethod(), params));
} catch (IOException e) {
return null;
}
};

return (T) cachedInformation.computeIfAbsent(keyHashCode, function);
BaseResponse response;
if ((response = cachedInformation.get(keyHashCode)) == null) {
try {
response = action.getResponse(requestManager.POST(method.getMethod(), params));
} catch (IOException e) {}
cachedInformation.put(keyHashCode, response);
}

return (T) response;
}

/**
Expand Down

0 comments on commit 30bab22

Please sign in to comment.