Fix lost responses and close handling; publish to Gitea as 0.2.0
Gradle Build / build (pull_request) Failing after 6s

- Register pending requests before sending so fast responses aren't lost
- Fail pending requests with SessionClosedException when the connection
  closes or errors, and add onClose(), isOpen() and a request overload
  with a timeout
- Serialize text sends: java.net.http.WebSocket allows only one
  outstanding send, so concurrent requests could throw
- Reassemble text messages delivered in parts before parsing
- Complete error responses with SessionErrorException carrying the payload
- Answer requests for unknown methods with an error response
- Fix SessionResult.error() producing success responses
- Fix close() using invalid close code 0; send 1000
- Publish as dev.selimaj:session-java to the Gitea package registry;
  make Jackson an api dependency and drop unused Tyrus/Jakarta deps
- Replace the empty test with 9 tests against an in-process server

Fixes #1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-09-25 14:28:04 +02:00
co-authored by claude
parent 563ea08a3f
commit 97eab5f814
10 changed files with 558 additions and 134 deletions
+28 -13
View File
@@ -3,13 +3,14 @@ plugins {
id 'maven-publish'
}
group = "dev.selimaj.session"
version = "0.1.3"
group = "dev.selimaj"
version = "0.2.0"
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
withSourcesJar()
}
repositories {
@@ -17,18 +18,15 @@ repositories {
}
dependencies {
// JSON parsing and serialization
implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.0'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.17.0'
implementation 'com.fasterxml.jackson.core:jackson-core:2.17.0'
// JSON parsing and serialization; JsonNode is part of the public API.
api 'com.fasterxml.jackson.core:jackson-databind:2.17.0'
api 'com.fasterxml.jackson.core:jackson-annotations:2.17.0'
api 'com.fasterxml.jackson.core:jackson-core:2.17.0'
// WebSocket API
implementation 'jakarta.websocket:jakarta.websocket-api:2.1.1'
// WebSocket client runtime
implementation 'org.glassfish.tyrus:tyrus-client:2.1.2'
// For testing
// For testing: a real WebSocket server for the client to talk to.
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation 'org.java-websocket:Java-WebSocket:1.6.0'
}
test {
@@ -38,7 +36,24 @@ test {
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'session-java'
from components.java
}
}
}
repositories {
// Gitea package registry. Publish with a token that has package:write:
// GITEA_TOKEN=... ./gradlew publish
maven {
name = 'Gitea'
url = uri('https://git.selimaj.dev/api/packages/selimaj-dev/maven')
credentials(HttpHeaderCredentials) {
name = 'Authorization'
value = "token ${findProperty('giteaToken') ?: System.getenv('GITEA_TOKEN') ?: ''}"
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
}