Skip to content

HDFS-17630. Avoid PacketReceiver#MAX_PACKET_SIZE Initialized to 0.#8329

Open
balodesecurity wants to merge 1 commit intoapache:trunkfrom
balodesecurity:HDFS-17630
Open

HDFS-17630. Avoid PacketReceiver#MAX_PACKET_SIZE Initialized to 0.#8329
balodesecurity wants to merge 1 commit intoapache:trunkfrom
balodesecurity:HDFS-17630

Conversation

@balodesecurity
Copy link

Summary

  • PacketReceiver.MAX_PACKET_SIZE was set via a static { new HdfsConfiguration(); ... } initializer. When config resources are loaded from HDFS URLs (e.g., during JAR loading via URLJarFile), the resulting class-loading chain can instantiate BlockReaderRemote before PacketReceiver finishes initializing. The JVM then returns the partially-initialized class with MAX_PACKET_SIZE == 0, causing every subsequent block read to throw IOException: Incorrect value for packet payload size.
  • Fix: initialize MAX_PACKET_SIZE directly to the compile-time default constant (eliminating the static initializer) and add a static setMaxPacketSize(Configuration) method that DFSClient calls during construction to apply any operator-configured override. This breaks the circular class-loading dependency while preserving configurability.

Test plan

  • New tests TestPacketReceiver#testMaxPacketSizeDefaultIsNonZero and TestPacketReceiver#testSetMaxPacketSizeFromConfig pass
  • All existing TestPacketReceiver tests continue to pass

The previous static initializer in PacketReceiver called
new HdfsConfiguration(), which loads config resources via URL connections.
If those URLs pointed to HDFS, the resulting class-loading chain could
instantiate BlockReaderRemote before PacketReceiver finished initializing,
causing the JVM to return the partially-initialized class with
MAX_PACKET_SIZE == 0. Any subsequent block read then failed with
"Incorrect value for packet payload size".

Fix: initialize MAX_PACKET_SIZE directly to the compile-time default
constant (removing the static initializer entirely) and introduce a
static setMaxPacketSize(Configuration) method that DFSClient calls
during construction to apply any configured override. This eliminates
the circular class-loading dependency while preserving configurability.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants