Skip to content

GH-1574 Fix SupplierExporter and FunctionEndpointInitializer lifecycle edge cases - #1578

Open
seonwooj0810 wants to merge 1 commit into
spring-cloud:mainfrom
seonwooj0810:fix/issue-1574-lifecycle
Open

seonwooj0810 wants to merge 1 commit into
spring-cloud:mainfrom
seonwooj0810:fix/issue-1574-lifecycle

Conversation

@seonwooj0810

Copy link
Copy Markdown
Contributor

Fixes #1574

  • SupplierExporter: when the stream completed while subscribing, stop() ran before subscription was assigned, threw a NullPointerException, and running was then set to true. The exporter is now marked as running before it subscribes, and stop() tolerates a missing subscription.
  • FunctionEndpointInitializer, missing beans: without a WebExceptionHandler it falls back to WebFluxResponseStatusExceptionHandler (the WebFlux default). Without an HttpHandler no server is started.
  • FunctionEndpointInitializer, non-daemon thread: I kept the thread non-daemon and stop the server when its context is closed instead. That thread is what keeps the JVM alive. Running a small FunctionalSpringApplication standalone:
context left open after context.close()
before JVM keeps running JVM keeps running
setDaemon(true) JVM exits once main returns not tried
this PR JVM keeps running JVM exits

Five regression tests added; all of them fail without the change.

Verification done: ./mvnw -pl spring-cloud-function-web clean install passes (256 tests, 0 failures, 25 skipped, checkstyle included). No other open PR or commit on main covers this issue.

…zer lifecycle edge cases

Mark SupplierExporter as running before subscribing and tolerate a missing
subscription in stop(), so a stream that completes while subscribing no
longer fails and leaves the exporter marked as running.

Do not fail in FunctionEndpointInitializer when there is no
WebExceptionHandler or HttpHandler bean.

Stop the HTTP server when its application context is closed. The startup
thread has to stay non-daemon since it keeps the JVM alive while the server
is running, but it now ends together with the context.

Resolves spring-cloud#1574

Signed-off-by: seonwoo_jung <79202163+seonwooj0810@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

SupplierExporter.stop() and FunctionEndpointInitializer fail on lifecycle edge cases

1 participant