{"record":{"id":"b77aea8e8c3691d4","repo":"apache/druid","slug":"compression-failed","errorCode":null,"errorMessage":"Compression failed","messagePattern":"Compression failed","errorType":"exception","errorClass":"RuntimeException","httpStatus":500,"severity":"error","filePath":"extensions-core/druid-pac4j/src/main/java/org/apache/druid/security/pac4j/Pac4jSessionStore.java","lineNumber":237,"sourceCode":"      }\n      catch (Exception e) {\n        LOGGER.debug(\"Failed to decrypt cookie value: %s\", e.getMessage());\n        throw InvalidInput.exception(e, \"Decryption failed. Check service logs.\");\n      }\n    }\n    return null;\n  }\n\n  private byte[] compress(final byte[] data)\n  {\n    try (ByteArrayOutputStream byteStream = new ByteArrayOutputStream(data.length)) {\n      try (GZIPOutputStream gzip = new GZIPOutputStream(byteStream)) {\n        gzip.write(data);\n      }\n      return byteStream.toByteArray();\n    }\n    catch (IOException ex) {\n      throw new RuntimeException(\"Compression failed\", ex);\n    }\n  }\n\n  private byte[] uncompress(final byte[] data)\n  {\n    try (ByteArrayInputStream inputStream = new ByteArrayInputStream(data);\n         GZIPInputStream gzip = new GZIPInputStream(inputStream)) {\n      return ByteStreams.toByteArray(gzip);\n    }\n    catch (IOException ex) {\n      throw new RuntimeException(\"Decompression failed\", ex);\n    }\n  }\n\n  /**\n   * Serialize object using standard Java serialization\n   */\n  private byte[] serializeToBytes(Serializable obj)","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/druid-pac4j/src/main/java/org/apache/druid/security/pac4j/Pac4jSessionStore.java#L219-L255","documentation":"Pac4jSessionStore.compress wraps GZIP compression of serialized session data destined for a cookie. GZIPOutputStream.write only throws IOException in genuinely exceptional situations since the output is an in-memory ByteArrayOutputStream, so this RuntimeException signals an unexpected internal failure (e.g. JVM-level stream corruption or OOM-adjacent conditions) rather than bad user input.","triggerScenarios":"Calling compressEncryptBase64 on a serialized session object while the internal GZIP write fails; practically only when the JVM is in a broken state (e.g. OutOfMemoryError surfaced as IOException) since both streams are in-memory.","commonSituations":"Very large session/profile objects stressing memory during cookie persistence; JVM resource exhaustion; rare JDK stream bugs.","solutions":["Inspect the cause chain (the IOException) to identify the underlying JVM resource problem","Reduce the size of the data being stored in the session/cookie","Check JVM heap availability and GC health at time of failure","Retry the request; this is almost never deterministic"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { byte[] compressed = store.compressEncryptBase64(obj); } catch (RuntimeException e) { LOGGER.error(e, \"Session compression failed\"); /* fail request or drop session */ }","preventionTips":["Keep cookie/session payloads small","Monitor JVM heap health","Alert on this exception; it should never fire in practice"],"tags":["compression","gzip","java-io"],"backgroundTag":"compression-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}