fix: unblock jcpan -t CPAN::Faker (Time::Piece %s, IO::Zlib, glob alias)#632
Merged
fix: unblock jcpan -t CPAN::Faker (Time::Piece %s, IO::Zlib, glob alias)#632
Conversation
Three PerlOnJava bugs surfaced while testing the CPAN::Faker chain (CPAN::Checksums, Archive::Any::Create, Text::Lorem, Data::Fake, Module::Faker, CPAN::Faker). All three are now fixed: 1. Time::Piece::strptime did not support %s (epoch seconds). Java's DateTimeFormatter has no strftime-style %s token, so Time::Piece->strptime($epoch, "%s") returned an empty list and then died in _mktime with "Day '' out of range 1..31". Special-case %s in TimePiece::_strptime to parse the input as a Long epoch directly. Fixes Data::Fake t/dates.t. 2. Compress::Zlib::gzopen failed on non-gzip files in 'rb' mode. zlib's gzopen transparently reads plain files, but Java's GZIPInputStream throws on missing gzip magic, so IO::Zlib->open returned undef and Archive::Tar->read($file, 1) reported "Could not create filehandle for ...". Peek at the first two bytes and fall back to a plain InputStream when the file isn't gzip-compressed. Fixes Archive::Any::Create t/01_tar.t. 3. Glob aliasing wasn't propagated through scalar-ref assignment. `local *SYM = *foo; *SYM = \$val` left $foo unchanged because RuntimeGlob.set(REFERENCE) only updated this.globName and ignored the alias group, while the ARRAYREFERENCE and HASHREFERENCE cases already iterated getGlobAliasGroup. Mirror that loop for the SCALAR case. Fixes Text::Template's _install_hash, and therefore Module::Faker t/makefile-pl.t and t/requires.t. After these fixes, `./jcpan -t CPAN::Faker` runs the whole dependency chain green. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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
Running
./jcpan -t CPAN::Fakerfailed in three different places in the dependency chain. Each failure traced back to a real PerlOnJava bug, all fixed in this PR:1.
Time::Piece::strptimedid not support%sJava's
DateTimeFormatterhas no strftime-style%s(epoch seconds) token, soTime::Piece->strptime($epoch, "%s")returned an empty list and_mktimethen died withDay '' out of range 1..31. Special-cased%sinTimePiece::_strptimeto parse the input as a Long epoch directly.Fixes
Data::Faket/dates.t.2.
Compress::Zlib::gzopenfailed on non-gzip files in'rb'modezlib's
gzopentransparently reads plain (uncompressed) files, but Java'sGZIPInputStreamthrows on missing gzip magic, soIO::Zlib->openreturnedundefandArchive::Tar->read($file, 1)reportedCould not create filehandle for .... Peek at the first two bytes and fall back to a plainInputStreamwhen the file isn't actually gzip-compressed.Fixes
Archive::Any::Createt/01_tar.t.3. Glob aliasing wasn't propagated through scalar-ref assignment
local *SYM = *foo; *SYM = \$valleft$foounchanged becauseRuntimeGlob.set(REFERENCE)only updatedthis.globNameand ignored the alias group, while the existingARRAYREFERENCEandHASHREFERENCEcases already iteratedgetGlobAliasGroup. Mirrored that loop for the SCALAR case.Fixes
Text::Template's_install_hash, and thereforeModule::Fakert/makefile-pl.tandt/requires.t.Test plan
make(full unit-test build) passes./jcpan -t CPAN::Fakernow runs the whole chain (CPAN::Checksums,Archive::Any::Create,Text::Lorem,Data::Fake,Module::Faker,CPAN::Faker) green:Time::Piece->strptime(1234567890, "%s")->strftime("%Y-%m-%dT%H:%M:%SZ")->2009-02-13T23:31:30ZIO::Zlibopens a plain tar file and reads it transparentlylocal *SYM = *main::x; *SYM = \$objupdates$main::xGenerated with Devin