Skip to content

fix(dedup): audit Spring/Logback allowlist and latch Dropwizard/Jersey async paths on call - #201

Merged
slayerjain merged 1 commit into
mainfrom
fix/spring-dropwizard-async-honesty-allowlist
Nov 29, 2026
Merged

slayerjain merged 1 commit into
mainfrom
fix/spring-dropwizard-async-honesty-allowlist

Conversation

@slayerjain

Copy link
Copy Markdown
Member

Problem

keploy/java-sdk v2.3.0 falsely latches asyncExecutors=false at startup on synchronous-only Spring Boot 2.7 (samples-java/java-dedup) and Dropwizard 2 (samples-java/dropwizard-dedup) REST apps, causing the >= 2.2.1 fail-closed gate to hold all duplicate removals (0 removed).

Root causes audited from live JAR bytecode (javap) on both apps:

  1. Spring Boot 2.7 (spring-core 5.3.x): org/springframework/util/ConcurrentLruCache uses a private ConcurrentLinkedDeque<K> queue under a ReentrantReadWriteLock synchronously inside get()/remove()/clear() solely for LRU eviction ordering (zero worker thread, zero executor).
  2. Dropwizard 2 (logback-core 1.2.x): ch/qos/logback/core/AsyncAppenderBase and ch/qos/logback/core/AsyncAppenderBase$Worker form Dropwizard's default async logging wrapper draining a BlockingQueue<E> of logging events into AppenderAttachableImpl.appendLoopOnAppenders (same logging-only sink category as already-allowlisted Tomcat org/apache/juli/AsyncFileHandler$LoggerExecutorService and Jetty org/eclipse/jetty/server/AsyncRequestLogWriter$WriterThread).
  3. Dropwizard 2 / Metrics / Jersey bootstrap classes: six framework classes (com/codahale/metrics/ScheduledReporter, com/codahale/metrics/health/AsyncHealthCheckDecorator, com/codahale/metrics/health/HealthCheckRegistry, io/dropwizard/servlets/tasks/LogConfigurationTask, org/glassfish/jersey/server/ChunkedOutput, org/glassfish/jersey/server/internal/JerseyRequestTimeoutHandler) are loaded unconditionally during server initialization even when never used for async/scheduled/streaming execution.

Solution

Keep the generic ConcurrentLinkedDeque / BlockingQueue / Thread / ExecutorService constant-pool fail-closed rules intact for all non-allowlisted classes, and apply exact, source-audited rules:

  • ServerEntries.ALLOWLISTED_DISPATCH_CLASSES (3 exact classes):
    • org/springframework/util/ConcurrentLruCache (synchronous private LRU eviction deque only)
    • ch/qos/logback/core/AsyncAppenderBase and ch/qos/logback/core/AsyncAppenderBase$Worker (logging-only event drain)
  • SinkAllowlist.INFRA_THREAD_CALLERS (1 exact caller):
    • ch.qos.logback.core.AsyncAppenderBase (allows start() spawning its single internal AsyncAppenderBase$Worker daemon thread)
  • ServerEntries.LATCH_ON_CALL (6 exact classes, fail-closed on invocation):
    • com/codahale/metrics/ScheduledReporter (start, getScheduledFuture)
    • com/codahale/metrics/health/AsyncHealthCheckDecorator (<init>, run)
    • com/codahale/metrics/health/HealthCheckRegistry (runHealthChecks(Ljava/util/concurrent/ExecutorService; — added descriptor-prefix matching to LatchEntry.matches so sync runHealthChecks() stays clean while parallel runHealthChecks(ExecutorService...) latches)
    • io/dropwizard/servlets/tasks/LogConfigurationTask (getTimer)
    • org/glassfish/jersey/server/ChunkedOutput (write, flushQueue, setContext)
    • org/glassfish/jersey/server/internal/JerseyRequestTimeoutHandler (suspend, setSuspendTimeout)

Verification

  • Unit tests (mvn -B test): Tests run: 461, Failures: 0, Errors: 0, Skipped: 3 (BUILD SUCCESS), including:
    • HonestProtocolAndAsyncTest.testSpringAndDropwizardAuditedAllowlistAndLatchOnCall: verifies all 3 allowlisted classes stay clean on load, 4 non-allowlisted classes referencing the exact same primitives (ConcurrentLinkedDeque.offer, BlockingQueue.offer, Thread subclass, ExecutorService.submit) still latch fail-closed on load, and all 6 LATCH_ON_CALL classes stay clean on load (and sync HealthCheckRegistry.runHealthChecks() stays clean) while latching asyncExecutors=false on first async/timer/streaming invocation.
    • JdkSinkBridgeTest.infraAllowlistContainsOnlyExactCitedZeroCallbackClassesAndExcludesUserCallbackPools: updated exact-count and behaviour pins for SinkAllowlist.INFRA_THREAD_CALLERS.
  • Live end-to-end sample proofs with honest-protocol gate enforced:
    • samples-java/java-dedup (Spring Boot 2.7, Java 8 / 17 / 21 × native, native-classpath): 382 duplicates removed / 18 retained (--keep 1), 346 duplicates removed / 54 retained (--keep 3) across all 6 combinations.
    • samples-java/dropwizard-dedup (Dropwizard 2, Java 8 / 17 / 21 × native, native-classpath): 180 duplicates removed / 20 retained (--keep 1), 142 duplicates removed / 58 retained (--keep 3) across all 6 combinations.
    • Legacy java-sdk 2.1.3 negative proof (dropwizard-dedup, Java 17 native): 0 duplicates removed / 200 retained, fail-closed warning logged.

…y async paths on call

Signed-off-by: slayerjain <shubhamkjain@outlook.com>
@slayerjain
slayerjain merged commit e28b8cb into main Nov 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant