{"record":{"id":"42e3c5612ad48266","repo":"spring-projects/spring-security","slug":"unable-to-deflate-string-42e3c5","errorCode":null,"errorMessage":"Unable to deflate string","messagePattern":"Unable to deflate string","errorType":"exception","errorClass":"Saml2Exception","httpStatus":null,"severity":"error","filePath":"saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/authentication/logout/Saml2Utils.java","lineNumber":61,"sourceCode":"\n\tstatic String samlEncode(byte[] b) {\n\t\treturn Base64.getEncoder().encodeToString(b);\n\t}\n\n\tstatic byte[] samlDecode(String s) {\n\t\treturn Base64.getMimeDecoder().decode(s);\n\t}\n\n\tstatic byte[] samlDeflate(String s) {\n\t\ttry {\n\t\t\tByteArrayOutputStream b = new ByteArrayOutputStream();\n\t\t\tDeflaterOutputStream deflater = new DeflaterOutputStream(b, new Deflater(Deflater.DEFLATED, true));\n\t\t\tdeflater.write(s.getBytes(StandardCharsets.UTF_8));\n\t\t\tdeflater.finish();\n\t\t\treturn b.toByteArray();\n\t\t}\n\t\tcatch (IOException ex) {\n\t\t\tthrow new Saml2Exception(\"Unable to deflate string\", ex);\n\t\t}\n\t}\n\n\tstatic String samlInflate(byte[] b) {\n\t\ttry {\n\t\t\tByteArrayOutputStream out = new ByteArrayOutputStream();\n\t\t\tInflaterOutputStream iout = new InflaterOutputStream(new CappedOutputStream(out), new Inflater(true));\n\t\t\tiout.write(b);\n\t\t\tiout.finish();\n\t\t\treturn new String(out.toByteArray(), StandardCharsets.UTF_8);\n\t\t}\n\t\tcatch (IOException ex) {\n\t\t\tthrow new Saml2Exception(\"Unable to inflate string\", ex);\n\t\t}\n\t}\n\n\tstatic EncodingConfigurer withDecoded(String decoded) {\n\t\treturn new EncodingConfigurer(decoded);","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/spring-projects/spring-security/blob/96852e8860138a482cb13d1479573f24ff6443c6/saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/authentication/logout/Saml2Utils.java#L43-L79","documentation":"Identical to the main Saml2Utils but located in the logout package: samlDeflate compresses a SAML logout message using raw DEFLATE for HTTP-Redirect binding. Saml2Exception \"Unable to deflate string\" is thrown on IOException during the in-memory deflate, which is practically a JVM-internal resource failure.","triggerScenarios":"logout Saml2Utils.samlDeflate(String s) writes to a DeflaterOutputStream over a ByteArrayOutputStream; the catch (IOException) branch throws — effectively only on memory exhaustion or Deflater failure during single-logout message encoding.","commonSituations":"Very large logout messages or constrained heap; transient JVM resource exhaustion while encoding SLO redirect URLs.","solutions":["Retry the logout operation — usually transient/environmental","Increase JVM heap if messages are very large","Inspect the wrapped cause for the actual failure and upgrade JVM if a java.util.zip defect is implicated"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (logoutXml == null || logoutXml.isEmpty()) {\n    throw new IllegalArgumentException(\"empty logout message, skip deflate\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    byte[] deflated = Saml2Utils.samlDeflate(logoutXml);\n} catch (Saml2Exception e) {\n    // transient/resource issue: retry or surface SLO failure\n}","preventionTips":["Keep logout messages small (few session indexes)","Ensure adequate heap","Retry transient failures and check the wrapped cause"],"tags":["saml2","logout","deflate","compression"],"backgroundTag":"compression-failed","analyzedSha":"96852e8860138a482cb13d1479573f24ff6443c6","analyzedAt":"2026-09-10T23:25:23.477Z","contentChangedAt":"2026-09-10T23:25:23.477Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}