{"record":{"id":"a88175061b8e06a5","repo":"ben-manes/caffeine","slug":"asynccache-required","errorCode":null,"errorMessage":"asyncCache required","messagePattern":"asyncCache required","errorType":"exception","errorClass":"InvalidObjectException","httpStatus":null,"severity":"error","filePath":"caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalAsyncCache.java","lineNumber":1709,"sourceCode":"    }\n  }\n\n  @SuppressWarnings(\"serial\")\n  final class SyncViewProxy<K, V> implements Serializable {\n    private static final long serialVersionUID = 1;\n\n    final AsyncCache<K, V> asyncCache;\n\n    SyncViewProxy(AsyncCache<K, V> asyncCache) {\n      this.asyncCache = requireNonNull(asyncCache);\n    }\n\n    @SuppressWarnings(\"unused\")\n    private void readObject(ObjectInputStream stream)\n        throws IOException, ClassNotFoundException {\n      stream.defaultReadObject();\n      if (asyncCache == null) {\n        throw new InvalidObjectException(\"asyncCache required\");\n      }\n    }\n\n    Object readResolve() {\n      return asyncCache.synchronous();\n    }\n  }\n}\n","sourceCodeStart":1691,"sourceCodeEnd":1718,"githubUrl":"https://github.com/ben-manes/caffeine/blob/9da6581ee366aa63c51e0dc96692d02f9c29ccff/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalAsyncCache.java#L1691-L1718","documentation":"SyncViewProxy is the serialization proxy for an AsyncCache's synchronous view; after defaultReadObject it validates that the transported asyncCache field is non-null and otherwise throws InvalidObjectException(\"asyncCache required\"). Seeing this error means the serialized proxy state was empty/corrupted — the stream claimed to be a proxy but carried no usable cache reference.","triggerScenarios":"A corrupted or hand-crafted stream where the SyncViewProxy's asyncCache field deserializes to null; partial stream truncation; serializers that strip final fields of proxies; streams from incompatible Caffeine versions with different proxy field layouts.","commonSituations":"Truncated network payloads or disk files holding serialized caches; serialization frameworks that skip non-serializable fields (leaving nulls); version skew between writer and reader.","solutions":["Re-serialize the cache from the source and verify the byte stream is intact end-to-end (checksums, length checks)","Ensure the Caffeine version on both sides matches so proxy fields deserialize fully","Avoid serializers that drop fields they deem non-serializable; whitelist Caffeine types or ship entry snapshots instead"],"exampleFix":"// before\nbyte[] payload = writeTruncated(cache); // cut off mid-stream\nObject o = readUnchecked(payload); // InvalidObjectException: asyncCache required\n\n// after\nbyte[] payload = write(cache);\nif (!checksum(payload).equals(expectedChecksum)) throw new IOException(\"corrupt payload\");\nObject o = read(payload); // proxy complete, validation passes","handlingStrategy":"validation","validationCode":"// Integrity-check serialized payloads before deserializing:\nbyte[] payload = readAll();\nif (!MessageDigest.isEqual(expectedChecksum, sha256(payload))) {\n  throw new IOException(\"Serialized cache payload corrupted; refusing to deserialize\");\n}\nObject o = new ObjectInputStream(new ByteArrayInputStream(payload)).readObject();","typeGuard":null,"tryCatchPattern":"try {\n  var cache = (Cache<K, V>) in.readObject();\n} catch (InvalidObjectException e) {\n  if (\"asyncCache required\".equals(e.getMessage())) {\n    // Proxy deserialized without its asyncCache field: stream is truncated/corrupt\n    throw new IOException(\"Corrupt SyncViewProxy payload; rebuild cache from snapshot\", e);\n  }\n  throw e;\n}","preventionTips":["Checksum serialized cache payloads (network and disk) and verify before reading","Match Caffeine versions between writer and reader so proxy fields survive","Keep a rebuild path (entry snapshot + loader) as the recovery route for corrupt caches"],"tags":["caffeine","serialization","proxy-validation","corrupted-stream","version-skew"],"backgroundTag":null,"analyzedSha":"9da6581ee366aa63c51e0dc96692d02f9c29ccff","analyzedAt":"2026-08-14T14:45:28.147Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}