diff --git a/src/org/bytedream/untis4j/CacheManager.java b/src/org/bytedream/untis4j/CacheManager.java index 5aec91e..cf72861 100755 --- a/src/org/bytedream/untis4j/CacheManager.java +++ b/src/org/bytedream/untis4j/CacheManager.java @@ -55,15 +55,21 @@ public T getOrRequest(UntisUtils.Method method, Request Function 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; } /**