Repository navigation
Replace Spark with Jetty 12 and virtual threads - #5
Merged
Merged
Conversation
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
Replace Spark Java / Jetty 9 with direct Jetty 12.1.13 integration and use Jetty's native server capabilities where they match the existing REST API semantics.
Jetty 12 migration
com.sparkjava:spark-coreand the old Jetty 9 stackorg.eclipse.jetty:jetty-server:12.1.13NoLoggingadapter andlog4j.propertiesGET /server/{placeholder}GET /{uuid}/{placeholder}Java 25 virtual threads
Jetty keeps its internal work on
QueuedThreadPoolwhile a managedVirtualThreadPoolis configured as the virtual-thread executor. Blocking application handlers therefore run through Jetty's adaptive execution strategy without moving PlaceholderAPI work onto the Minecraft main thread.Reload lifecycle operations also use a dedicated single virtual-thread executor rather than the common ForkJoinPool.
Native Jetty features adopted
PathMappingsHandler.NoContext+UriTemplatePathSpecreplace Spark routing.QoSHandlerreplaces the customSemaphore;max-concurrentremains fail-fast with JSON HTTP 503 and no suspended request queue.InetAccessHandlerreplaces manual socket-peer checks and adds native address/CIDR pattern support while still using the real connection address rather than forwarded headers.GracefulHandlerdrains in-flight requests while rejecting new work with JSON HTTP 503.shutdown-timeout-msdefaults to 5000 ms and is valid from 100 to 30000 ms.Server/ServerConnectorlifecycle replaces Spark initialization and shutdown wrappers.Intentionally retained application logic
DoSHandleruses rate/leaky-bucket semantics, which is not equivalent to the existingrate-limit.requests+ arbitrarywindow-secondscontract.RequestLimiteris retained to avoid a behavioral/configuration change.Tokenheader and constant-time comparison remain because Jetty's general security framework would add unnecessary machinery and change the API authentication model.{status,message}payload.Threading behavior
Both player and server placeholder endpoints remain off the Minecraft main thread:
Bukkit.getOfflinePlayer(UUID)+PlaceholderAPI.setPlaceholders(...)PlaceholderAPI.setPlaceholders(null, ...)Third-party PlaceholderAPI expansions queried by this service must support off-thread execution.
Validation
GitHub Actions passed on Java 25:
bash gradlew test shadowJar --no-daemonThe build includes compilation against Jetty 12.1.13, unit tests, and creation of the shaded plugin JAR.