Merged
Conversation
d5c8c8b to
846d4d8
Compare
Three independent bugs surfaced by LWP::UserAgent::Mockable's
record/playback test suite:
1. IO::Socket::INET with Timeout always failed with EIO.
SocketIO.connect() was auto-binding the local NIO socket to the
target's IP address, which fails with BindException for any remote
target. Bind to the wildcard address (0.0.0.0:0) instead and make
the bind best-effort.
2. Storable::dclone died on objects whose package inherits AUTOLOAD
(e.g. HTTP::Request via HTTP::Message::AUTOLOAD).
InheritanceResolver.findMethodInHierarchy falls back to AUTOLOAD,
but Storable's STORABLE_freeze/thaw lookup must NOT — Perl's real
Storable uses gv_fetchmethod_autoload(..., FALSE). Added a
checkAutoload parameter (with a separate cache slot) and used it
for all STORABLE_freeze / STORABLE_thaw lookups.
3. Storable::retrieve broke URI overload globally and passed the wrong
reference kind to STORABLE_thaw.
- SX_HOOK and !!perl/freeze: records didn't encode the original
reference type, so on read we always built a hash ref; URI's
STORABLE_thaw does "$$self = $str" and died with "Not a SCALAR
reference". Encode the ref type (S/A/H byte for binary,
freezeS: / freezeA: / freeze: tag prefix for YAML); reader
builds a scalar / array / hash ref accordingly. The plain
"freeze:" tag is still accepted on read for backward
compatibility.
- Blessing into a class before it's loaded allocates a *positive*
(non-overloaded) blessId that is then cached forever; later
"URI->new(...)" skipped overload dispatch and "$uri" stringified
as "URI::http=SCALAR(0x...)". On retrieve, best-effort require
the class before bless so its overload registers first.
jcpan -t LWP::UserAgent::Mockable now passes all 73 tests across 14
files; all PerlOnJava unit tests still green.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
846d4d8 to
9210e35
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes three independent bugs surfaced by
jcpan -t LWP::UserAgent::Mockable. After the fix, all 73 tests across the 14 test files pass.1.
IO::Socket::INETwithTimeoutalways failed (EIO)SocketIO.connect()was auto-binding the local NIO socket to the target's IP address, which fails withBindException: Can't assign requested addressfor any remote host — surfacing as a bogusInput/output error($! = EIO). Now binds to the wildcard address (0.0.0.0:0) instead, best-effort.2.
Storable::dclonedied on objects whose package inherits AUTOLOADInheritanceResolver.findMethodInHierarchyfalls back to AUTOLOAD when a method isn't found, but Storable'sSTORABLE_freeze/STORABLE_thawlookup must NOT — Perl's real Storable usesgv_fetchmethod_autoload(..., FALSE). With AUTOLOAD fallback enabled, our code tried to invokeHTTP::Message::AUTOLOADasSTORABLE_freezeand crashed withCan't locate object method "" via package "".Added a
checkAutoloadparameter (with a separate cache slot) tofindMethodInHierarchyand used it for allSTORABLE_freeze/STORABLE_thawlookups.3.
Storable::retrievebroke URI overload globally and built the wrong reference kind forSTORABLE_thawTwo sub-issues:
The
SX_HOOKand!!perl/freeze:records didn't encode the original reference type, so on read we always built a hash ref. URI'sSTORABLE_thawdoes$$self = $strand croaks withNot a SCALAR reference. Now encode the ref type (S/A/H byte for binary;freezeS:/freezeA:/freeze:tag prefix for YAML); the reader builds a scalar / array / hash ref accordingly. The plainfreeze:tag is still accepted on read for backward compatibility.Blessing into a class before it's loaded allocates a positive (non-overloaded) blessId. That id is cached forever, so even after the class is later loaded with
use overload, every subsequentURI->new(...)skipped overload dispatch — strings printed asURI::http=SCALAR(0x...)andeqcomparisons failed. On retrieve, best-effortrequirethe class beforeblessso its overload registers first.Test plan
jcpan -t LWP::UserAgent::Mockable—Result: PASS(wasFAIL— 7 of 14 test files dubious / non-zero exit).make(full unit test suite) — green.Configuration.javaupdated byinjectGitInfo.