-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
fix(online): thread-safe fileMap with TTL cleanup, SLF4J logging, and Content-Length header #24011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vikas0686
wants to merge
6
commits into
OpenAPITools:master
Choose a base branch
from
vikas0686:f/vikas/openapi-generator/use-concurrent-hash-map
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
92d6c23
fix : thread safety, logging, and Content-Length in openapi-generator…
vikas0686 f418c78
fix : thread-safe fileMap with 24h TTL cleanup in openapi-generator-o…
vikas0686 3aaaa56
fix(online): enforce TTL at download time and make createdAt immutable
vikas0686 67631d7
fix : updated the failing test cases for GenApiControllerTest
vikas0686 5720305
fix: Add GenApiServiceTest with TTL cleanup and concurrent generation…
vikas0686 709a677
fix(online): retain fileMap entry when temp directory deletion fails
vikas0686 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
46 changes: 46 additions & 0 deletions
46
...rator-online/src/test/java/org/openapitools/codegen/online/service/GenApiServiceTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package org.openapitools.codegen.online.service; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: Cleanup is not guaranteed if the assertion fails, so this test can leak state into the shared GenApiService and leave temporary files behind. Prompt for AI agents |
||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import org.openapitools.codegen.online.model.Generated; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
|
|
||
| import java.time.Instant; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.*; | ||
|
|
||
| @SpringBootTest | ||
| public class GenApiServiceTest { | ||
|
|
||
| @Autowired | ||
| private GenApiService genApiService; | ||
|
|
||
| // Fix #1: TTL cleanup removes expired entries | ||
| @Test | ||
| public void cleanExpiredFilesRemovesExpiredEntry() { | ||
| Generated entry = new Generated(); | ||
| entry.setFilename("/tmp/codegen-test/bundle.zip"); | ||
|
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
|
||
| entry.setFriendlyName("test"); | ||
| entry.setCreatedAt(Instant.now().minusSeconds(25 * 3600)); // 25h ago, beyond 24h TTL | ||
| genApiService.putFileEntry("test-expired-key", entry); | ||
|
|
||
| genApiService.cleanExpiredFiles(); | ||
|
|
||
| assertNull(genApiService.getFileEntry("test-expired-key"), "Expired entry should have been evicted"); | ||
| } | ||
|
|
||
| // Fix #1: recent entry is not evicted by cleanup | ||
| @Test | ||
| public void cleanExpiredFilesKeepsRecentEntry() { | ||
| Generated entry = new Generated(); | ||
| entry.setFilename("/tmp/codegen-test/bundle.zip"); | ||
| entry.setFriendlyName("test"); | ||
| // createdAt defaults to Instant.now() — well within 24h TTL | ||
| genApiService.putFileEntry("test-recent-key", entry); | ||
|
|
||
| genApiService.cleanExpiredFiles(); | ||
|
|
||
| assertNotNull(genApiService.getFileEntry("test-recent-key"), "Recent entry should not be evicted"); | ||
| genApiService.removeFileEntry("test-recent-key"); | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.