@Override
    public HttpCacheStorageEntry deserialize(final byte[] serializedObject) throws ResourceIOException {
        if (serializedObject == null || serializedObject.length == 0) {
            throw new ResourceIOException("Serialized object is null or empty");
        }
        try (final InputStream in = new ByteArrayInputStream(serializedObject)) {
            final SessionInputBufferImpl inputBuffer = new SessionInputBufferImpl(bufferSize);
            final CharArrayBuffer line = new CharArrayBuffer(DEFAULT_BUFFER_SIZE);
            checkReadResult(inputBuffer.readLine(line, in));
            final String versionLine = line.toString();
            if (!versionLine.equals(HC_CACHE_VERSION_LINE)) {
                throw new ResourceIOException("Unexpected cache entry version line");
            }
            String storageKey = null;
            long length = -1;
            Instant requestDate = null;
            Instant responseDate = null;
            final Set<String> variants = new HashSet<>();

            while (true) {
                line.clear();
                checkReadResult(inputBuffer.readLine(line, in));
                if (line.isEmpty()) {
                    break;
                }
                final Header header = lineParser.parseHeader(line);
                final String name = header.getName();
                final String value = header.getValue();
                if (name.equalsIgnoreCase(HC_CACHE_KEY)) {
                    storageKey = value;
                } else if (name.equalsIgnoreCase(HC_CACHE_LENGTH)) {
                    length = asLong(value);
                } else if (name.equalsIgnoreCase(HC_REQUEST_INSTANT)) {
                    requestDate = asInstant(value);
                } else if (name.equalsIgnoreCase(HC_RESPONSE_INSTANT)) {
                    responseDate = asInstant(value);
                } else if (name.equalsIgnoreCase(HC_VARIANT)) {
                    variants.add(value);
                } else {
                    throw new ResourceIOException("Unexpected header entry");
                }
            }

            if (storageKey == null || requestDate == null || responseDate == null) {
                throw new ResourceIOException("Invalid cache header format");
            }

            line.clear();
            checkReadResult(inputBuffer.readLine(line, in));
            final RequestLine requestLine = lineParser.parseRequestLine(line);
            final HeaderGroup requestHeaders = new HeaderGroup();
            while (true) {
                line.clear();
                checkReadResult(inputBuffer.readLine(line, in));
                if (line.isEmpty()) {
                    break;
                }
                requestHeaders.addHeader(lineParser.parseHeader(line));
            }
            line.clear();
            checkReadResult(inputBuffer.readLine(line, in));
            final StatusLine statusLine = lineParser.parseStatusLine(line);
            final HeaderGroup responseHeaders = new HeaderGroup();
            while (true) {
                line.clear();
                checkReadResult(inputBuffer.readLine(line, in));
                if (line.isEmpty()) {
                    break;
                }
                responseHeaders.addHeader(lineParser.parseHeader(line));
            }

            final Resource resource;
            if (length != -1) {
                int off = 0;
                int remaining = (int) length;
                final byte[] buf = new byte[remaining];
                while (remaining > 0) {
                    final int i = inputBuffer.read(buf, off, remaining, in);
                    if (i > 0) {
                        off += i;
                        remaining -= i;
                    }
                    if (i == -1) {
                        throw new ResourceIOException("Unexpected end of cache content");
                    }
                }
                resource = new HeapResource(buf);
            } else {
                resource = null;
            }
            if (inputBuffer.read(in) != -1) {
                throw new ResourceIOException("Unexpected content at the end of cache content");
            }

            final HttpCacheEntry httpCacheEntry = new HttpCacheEntry(
                    requestDate,
                    responseDate,
                    requestLine.getMethod(),
                    requestLine.getUri(),
                    requestHeaders,
                    statusLine.getStatusCode(),
                    responseHeaders,
                    resource,
                    !variants.isEmpty() ? variants : null
            );

            if (LOG.isDebugEnabled()) {
                LOG.debug("Returning deserialized cache entry with storage key '{}'", httpCacheEntry);
            }

            return new HttpCacheStorageEntry(storageKey, httpCacheEntry);
        } catch (final ResourceIOException ex) {
            throw ex;
        } catch (final ParseException ex) {
            throw new ResourceIOException("Invalid cache header format", ex);
        } catch (final IOException ex) {
            throw new ResourceIOException("I/O error deserializing cache entry", ex);
        }
    }
Deserializes a byte array representation of an HTTP cache storage entry into an instance of
{@link HttpCacheStorageEntry}.

@param serializedObject the byte array representation of the HTTP cache storage entry
@return the deserialized HTTP cache storage entry
@throws ResourceIOException if an error occurs during deserialization
httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/HttpByteArrayCacheEntrySerializer.java