@@ -23,6 +23,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="archive,mapping" {
2323 _buildHybridPhysicalFirst ();
2424 _buildMissingPhysical ();
2525 _buildMissingArchive ();
26+ _buildCorruptArchive ();
2627 }
2728
2829 function afterAll () {
@@ -73,8 +74,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="archive,mapping" {
7374
7475 describe ( " Hybrid physical + archive with primary=archive" , function () {
7576
76- it ( title = " should prefer archive over physical when primary is archive" , skip = true , body = function () {
77- // LDEV-6172: initPhysical() overrides physicalFirst before archive init
77+ it ( title = " should prefer archive over physical when primary is archive" , body = function () {
7878 var result = _internalRequest (
7979 template : " #_uri () #/hybrid/index.cfm" ,
8080 urls : { scene : " archive" }
@@ -130,6 +130,17 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="archive,mapping" {
130130
131131 });
132132
133+ describe ( " Graceful fallback when archive is corrupt" , function () {
134+
135+ it ( " should fall back to physical when archive is not a valid LAR" , function () {
136+ var result = _internalRequest (
137+ template : " #_uri () #/corruptArchive/index.cfm"
138+ );
139+ expect ( result .fileContent .trim () ).toBe ( " from-physical" );
140+ });
141+
142+ });
143+
133144 }
134145
135146 // ---- archive builders ----
@@ -244,6 +255,17 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="archive,mapping" {
244255 // intentionally do NOT create physDir
245256 }
246257
258+ private function _buildCorruptArchive () {
259+ var corruptLar = variables .testDir & " corrupt.lar" ;
260+ var physDir = variables .testDir & " corruptArchive-physical/" ;
261+
262+ // write garbage bytes — not a valid JAR/ZIP
263+ fileWrite ( corruptLar , repeatString ( " NOT A VALID LAR FILE" , 100 ) );
264+
265+ directoryCreate ( physDir , true , true );
266+ fileWrite ( physDir & " hello.cfm" , " <cfset writeOutput( 'from-physical' )>" );
267+ }
268+
247269 private function _buildMissingArchive () {
248270 // archive path points to a non-existent .lar, physical is valid
249271 var physDir = variables .testDir & " missingArchive-physical/" ;
0 commit comments