[GEODE-10523] 2.0 RELEASE BLOCKER : gfsh issues after Spring Shell 3 migration #7958
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.
Description
This PR fixes a missing banner issue, a history file migration issue and a critical bug where
gfshfails to start with aNullPointerExceptionafter the Spring Shell 1.x to 3.x migration.Related JIRA: GEODE-10523
Problem
After migrating to Spring Shell 3.x, running
gfshresults in:Additionally, two other issues were discovered:
Root Cause
Spring Shell 1.x automatically initialized the terminal and line reader during startup. Spring Shell 3.x requires explicit initialization of these components before use. The
Gfsh.run()method was callingpromptLoop()without initializing the terminal or creating the console reader first.Solution
1. Terminal Initialization
Added
initializeTerminal()method to explicitly create and initialize the JLine 3 Terminal:Modified
run()method to initialize terminal and create console reader before entering prompt loop:2. History File Migration
Implemented automatic migration from JLine 2 format (with
//comments) to JLine 3 format (clean format):In
Gfsh.java:In
GfshHistory.java:3. Banner Display Fix
Modified
printAsInfo()to always print to stdout in addition to logging:Files Modified
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/shell/Gfsh.javainitializeTerminal()methodmigrateHistoryFileIfNeeded()methodrun()method to initialize terminal before prompt loopprintAsInfo()to output to stdoutjava.nio.file.Files,java.nio.file.Pathgeode-gfsh/src/main/java/org/apache/geode/management/internal/cli/shell/jline/GfshHistory.javaattach()method with exception handlingmigrateOldHistoryFile()method for format migrationTesting
Build Verification
Result: BUILD SUCCESSFUL
Verified:
.gfsh_history.old)Example Output
Impact
Checklist
For all changes, please confirm:
develop)?gradlew buildrun cleanly?