Repository navigation
fix(dedup): fail closed on Logback app extensions, latch XML scan reload at call site, and cover LATCH_ON_CALL methods - #202
Open
slayerjain wants to merge 2 commits into
Open
slayerjain wants to merge 2 commits into
slayerjain wants to merge 2 commits into
Conversation
…ase and cover all LATCH_ON_CALL methods Signed-off-by: slayerjain <shubhamkjain@outlook.com>
…gback XML scan reload at call site Signed-off-by: slayerjain <shubhamkjain@outlook.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
Closes the remaining Logback and
LATCH_ON_CALLcoverage-honesty gaps forv2.3.2:Fail closed on ANY app-included
ch/qos/logback/supertype whenAsyncAppenderBaseis active:ch/qos/logback/), direct or transitive, so every Logback worker-invoked SPI (Appender,Encoder,Layout,Converter,Filter,TurboFilter,Discriminator/AbstractDiscriminator,StatusListener,IThrowableRenderer,ConnectionSource,RollingPolicy,TriggeringPolicy, and any future SPI) fails closed by construction.AsyncAppenderBasefirst or app extension first), routesSinkAllowlist.isAllowlistedThreadStartCaller("ch.qos.logback.core.AsyncAppenderBase")throughServerEntries.noteLogbackAsyncAppenderAndCheckSafe(), explores superclass chains ahead of interface lists (cap 64) during read-only.classresource walks, and negatively caches fully resolved non-Logback supertypes (bounded at 32,768 entries) to avoid repeated.classreads on large apps.Why fail-closed instead of tracking
AsyncAppenderBase.put:$jacocoDataprobe array is global per class rather than per thread, andAsyncAppenderBase$Workeris a single shared daemon thread draining events queued by concurrent requests and background threads. Waiting onput()would still allow request A's custom appender/layout/converter/discriminator probes onWorkerto bleed into request B's window, while dropped events (isDiscardable/neverBlock=true) or queue drain delays beyondEND_WAIT_MSwould under-report coverage. Failing closed guarantees coverage never under-reports or cross-contaminates, with zero runtime overhead on standard apps.Latch Logback XML
scan="true"reload at the dispatch call site instead of on class load:logback.xmlorlogback-spring.xml) was held asasyncExecutors=falseeven withoutscan="true"orAsyncAppender, because the load-time constant-pool scan latched onScheduledExecutorService.scheduleAtFixedRateinsidech/qos/logback/classic/joran/action/ConfigurationAction(Logback 1.2.x) andch/qos/logback/classic/model/processor/ConfigurationModelHandlerFull(Logback 1.3.x–1.5.x).processScanAttrib/detachedPostProcesson every<configuration>element and return early unlessscanis enabled. Added call-site latching (addLatchOnDispatchCall) toServerEntries.LATCH_ON_CALLfor both classes sowrapLatchOnCallhooks everyDISPATCH_PRIMITIVE_METHODScall site (ScheduledExecutorService.scheduleAtFixedRate, etc.) directly before invocation, firingRequestGate.noteRuntimeUntrackedDispatch("logback-scan-reload:...")only when ascan="true"reload task is actually scheduled.scan(including Spring Bootlogback-spring.xmlwith<include>and<springProfile>) now retainasyncExecutors=true, whilescan="true"latchesasyncExecutors=falseimmediately.Add all missing
LATCH_ON_CALLtest rows and call-site / package-rule tests (HonestProtocolAndAsyncTest):ScheduledReporter.getScheduledFuture(metrics 4.2.x exact 5-arg signature),JerseyRequestTimeoutHandler.setSuspendTimeout,ChunkedOutput.flushQueue,ChunkedOutput.setContext,HealthCheckRegistry.runHealthChecks(ExecutorService, Object)(2-arg overload + sync overloads stay clean), andAsyncHealthCheckDecorator.run().testLogbackAsyncAppenderFailsClosedOnAppIncludedExtensions: covers framework-only clean, all direct Logback extension categories includingAbstractDiscriminator,StatusListener, andIThrowableRenderer, both load orders,SinkAllowlistruntime fallback, transitive framework/pre-loaded hierarchies, superclass-first priority behind 20 wide interfaces, and negative-cache reuse.testLogbackXmlScanReloadLatchesOnlyWhenScanScheduled: covers bothConfigurationAction(1.2.x) andConfigurationModelHandlerFull(1.3.x–1.5.x) — clean on class load, clean onscan=false, immediate pre-call latch onscan=true(even with a mockScheduledExecutorService), and re-transform idempotency.Verification
All checks ran against committed SHA
d09336607526a8c3e024a9a5a1b702bf93b009e0:mvn -B -pl keploy-sdk -am test):1.8.0_452): 463 run, 0 failures, 0 errors, 10 skipped —BUILD SUCCESS11.0.27): 463 run, 0 failures, 0 errors, 8 skipped —BUILD SUCCESS17.0.15): 463 run, 0 failures, 0 errors, 5 skipped +mvn -P release -Dgpg.skip -DskipTests clean verify+./scripts/smoke-javaagent.sh—BUILD SUCCESS21.0.7): 463 run, 0 failures, 0 errors, 3 skipped —BUILD SUCCESSdrop_getScheduledFuture,drop_setSuspendTimeout,drop_flushQueue,drop_setContext,narrow_runHealthChecks_to_1arg,drop_AsyncHealthCheckDecorator_run,disable_inspectLogbackAsyncExtension,drop_sinkallowlist_logback_gate,drop_ConfigurationAction_latch,drop_ConfigurationModelHandlerFull_latchs0-async-plain(XML no scan, stockAsyncAppender): clean (DISPATCHERS=[],RUNTIME_LATCH=false) on both 1.2.13 and 1.5.12s1-async-converter(XML +AsyncAppender+ app converter via intermediate): latched (logback-async-app-extension) on boths2-async-sift(XML +AsyncAppender+SiftingAppender+ appTenantDiscriminator): latched (logback-async-app-extension) on boths3-sync-converter(XML sync + app converter): clean on boths4-scan-true(XMLscan="true"): latched (RUNTIME_LATCH=true) on boths5-scan-false(XMLscan="false"): clean on bothkeployE+ localkeploy-sdk-2.3.2.jar):java-dedupdefault (Spring Boot 2.7, Java 17 native):covered=400, duplicates=382/346, retained=18/54(unchanged)java-dedupXMLlogback-spring.xmlwithoutscan(<include>+<springProfile>):covered=400, duplicates=382/346, retained=18/54(asyncExecutors=true)java-dedupXMLlogback-spring.xmlwithscan="true": held (asyncExecutors=false),covered=400, duplicates=0, retained=400dropwizard-dedup6/6 (Java 8, 17, 21 xnative,native-classpath):covered=200, duplicates=180/142, retained=20/58across all 6 cells (unchanged)