fix: check Optional.isPresent() before calling get() in DocxGenerator (#3721)#1
Open
ADITYA-CODE-SOURCE wants to merge 8 commits into
Open
fix: check Optional.isPresent() before calling get() in DocxGenerator (#3721)#1ADITYA-CODE-SOURCE wants to merge 8 commits into
ADITYA-CODE-SOURCE wants to merge 8 commits into
Conversation
- Add 10 LicenseDB configuration constants to SW360Constants.java - Update sw360.properties in 3 locations - Add LicenseDBConstantsTest.java with unit tests - Fix CI: Configure CouchDB for single-node operation This is Phase 1 of LicenseDB integration for GSoC 2026. Signed-off-by: ADITYA-CODE-SOURCE <adityavishe67@gmail.com>
- Add LICENSEDB to ConfigFor enum in sw360.thrift - Add LICENSEDB_ID constant to SW360Constants - Add LicenseDBConfig.java: OAuth and connection configuration - Add LicenseDBRestClient.java: OAuth2 client credentials flow - Add LicenseDBService.java: License and obligation sync logic - Add LicenseDBController.java: Admin REST endpoints This implements the core OAuth/M2M integration with LicenseDB. Signed-off-by: ADITYA-CODE-SOURCE <adityavishe67@gmail.com>
- Use constructor injection instead of RestTemplateBuilder - Fix property prefix to match sw360.properties - Use Spring's auto-configured RestTemplate bean Signed-off-by: ADITYA-CODE-SOURCE <adityavishe67@gmail.com>
- Add COUCHDB_CLUSTER_SIZE=1 to ensure single-node mode - Add health check for CouchDB container - Use -s flag for curl to suppress error output - Add quotes around values for JSON compatibility - Add || true to prevent step failure on errors Signed-off-by: Aditya Vishe <adityavishe67@gmail.com>
Fixes eclipse-sw360#3721 The generateOutputFile() method was calling .get() on Optional before checking .isPresent(), causing NoSuchElementException when the template file is missing. Now checks isPresent() first and throws proper SW360Exception with helpful message.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes eclipse-sw360#3721 - DocxGenerator crashes with NoSuchElementException when template file is missing
Bug
In
DocxGenerator.generateOutputFile(), the code was calling.get()on theOptionalbefore checking.isPresent(). This caused a rawNoSuchElementExceptioninstead of the intendedSW360Exceptionwith a helpful "Could not load the template" message.Fix
Reordered the code to check
isPresent()first before calling.get():xwpfDocument = new XWPFDocument(...)inside theif (docxTemplateFile.isPresent())blockThis ensures proper error handling when the template file is missing or fails to load.