Skip to content

Rewrite lib-data-stream-redis production code from Groovy to Java#50

Merged
pditommaso merged 3 commits intomasterfrom
lib-data-stream-redis-java-rewrite
Feb 20, 2026
Merged

Rewrite lib-data-stream-redis production code from Groovy to Java#50
pditommaso merged 3 commits intomasterfrom
lib-data-stream-redis-java-rewrite

Conversation

@pditommaso
Copy link
Contributor

@pditommaso pditommaso commented Jan 7, 2026

Summary

Converts all production source files in lib-data-stream-redis from Groovy to pure Java while keeping tests in Groovy/Spock. This removes the Groovy runtime dependency from production code.

Files converted

Groovy File Java File
AbstractMessageStream.groovy AbstractMessageStream.java
MessageConsumer.groovy MessageConsumer.java
MessageStream.groovy MessageStream.java
impl/LocalMessageStream.groovy impl/LocalMessageStream.java
impl/RedisMessageStream.groovy impl/RedisMessageStream.java
impl/RedisStreamConfig.groovy impl/RedisStreamConfig.java

Key Groovy-to-Java conversions

Groovy Feature Java Equivalent
@Slf4j annotation private static final Logger log = LoggerFactory.getLogger(...)
@CompileStatic Removed (Java is statically typed)
@Memoized Removed (not critical for simple millis conversion)
GString "${var}" String concatenation or String.format()
def keyword Explicit types
Safe navigation ?. Explicit null checks
Elvis operator ?: Ternary operator
final local vars Explicit final or mutable vars
return in finally block (suppresses exceptions) Catch exception without rethrowing (see note below)

Note on exception handling in LocalMessageStream.consume()

In Groovy, having return result inside a finally block suppresses any exception thrown in the try/catch block. The original code relied on this behavior to catch consumer exceptions and return false instead of propagating the exception.

In Java, this was converted to explicitly catch the exception without rethrowing:

catch (Throwable e) {
    result = false;
    // exception is caught but not rethrown - message will be re-queued
}

build.gradle changes

  • Removed io.seqera.groovy-library-conventions plugin
  • Changed Groovy dependencies from implementation to testImplementation
  • Kept groovy plugin for test compilation (Spock tests remain in Groovy)

Test plan

  • All 8 existing tests pass
  • Production code compiles without Groovy dependencies
  • Review generated Java code for correctness

🤖 Generated with Claude Code

Convert all production source files from Groovy to pure Java while
keeping tests in Groovy/Spock. This removes the Groovy runtime
dependency from production code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
pditommaso and others added 2 commits February 20, 2026 20:40
# Conflicts:
#	lib-data-stream-redis/build.gradle
#	lib-data-stream-redis/src/main/java/io/seqera/data/stream/impl/RedisMessageStream.java
Add a SleepHelper utility to replace verbose try/catch sleep patterns.
Use final declarations and var where applicable to match Groovy style.
Add debug logging for caught exceptions in LocalMessageStream.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@pditommaso pditommaso marked this pull request as ready for review February 20, 2026 20:25
@pditommaso pditommaso merged commit 9920495 into master Feb 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant