From 4e6d8fbfa3d11b491105c12b579727522aa7e836 Mon Sep 17 00:00:00 2001 From: Evgenii Kliuchnikov Date: Wed, 8 Jul 2026 01:13:34 -0700 Subject: [PATCH] Retain source data for prepared dictionary. Unlike pure-java prepared dictionary, in native prepared dictionaries source data is not copied, but referenced. Likely because of copy-paste, `raw_data` field was not populated. PiperOrigin-RevId: 944339020 --- java/org/brotli/wrapper/enc/EncoderJNI.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/java/org/brotli/wrapper/enc/EncoderJNI.java b/java/org/brotli/wrapper/enc/EncoderJNI.java index 2f7ef30..888d537 100644 --- a/java/org/brotli/wrapper/enc/EncoderJNI.java +++ b/java/org/brotli/wrapper/enc/EncoderJNI.java @@ -35,6 +35,8 @@ class EncoderJNI { private PreparedDictionaryImpl(ByteBuffer data, ByteBuffer rawData) { this.data = data; + // Retain a reference to the raw data to prevent it from being garbage collected. + this.rawData = rawData; } @Override