Skip to content

Modernize demo dependencies and runtime cleanup#5

Open
adrianmilne wants to merge 1 commit intomasterfrom
codex/describe-repository-contents
Open

Modernize demo dependencies and runtime cleanup#5
adrianmilne wants to merge 1 commit intomasterfrom
codex/describe-repository-contents

Conversation

@adrianmilne
Copy link
Owner

Motivation

  • Bring the project up-to-date for modern JVM/tooling by targeting Java 11 and newer Spring/JUnit versions and removing fragile legacy configuration in pom.xml.
  • Fix runtime resource/lifecycle issues: close Spring context, stop executor threads, wait for generators to finish, and ensure Esper provider/statements are torn down to avoid leaks.
  • Improve correctness and maintainability of the event model and observability by making TemperatureEvent immutable with defensive copies and adjusting logging severities for alert types.

Description

  • Update pom.xml to target Java 11, bump Spring to 5.3.34, add JUnit 5 and modern Maven plugins and maven-surefire-plugin to enable tests and modern compilation behavior.
  • Revise the demo entrypoint StartDemo to validate arguments (parseNumberOfEvents), use try-with-resources for ClassPathXmlApplicationContext, and wait for the generator Future to complete.
  • Change RandomTemperatureEventGenerator to return a Future<?>, use ThreadLocalRandom, handle interruptions properly, and shut down the single-thread executor when finished.
  • Harden TemperatureEvent by making it final, using final fields, performing defensive copies of Date values, and adding equals/hashCode.
  • Add Esper lifecycle cleanup by implementing DisposableBean in TemperatureEventHandler and destroying created EPStatements and the EPServiceProvider in destroy().
  • Adjust logging severities for subscribers so critical events use LOG.error, warnings use LOG.warn, and monitor output uses LOG.info.
  • Add a unit test src/test/java/com/cor/cep/event/TemperatureEventTest.java that verifies defensive copying of the timestamp.

Testing

  • Ran mvn test in the environment but the build failed due to inability to download a Maven plugin from Maven Central (HTTP 403), so tests could not be executed here; the new JUnit 5 test file was added but not run successfully under the constrained environment.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant