Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-76 Add delay#76

Open
Jakubk15 wants to merge 3 commits intomaster from
feature/delay
Open

GH-76 Add delay #76
Jakubk15 wants to merge 3 commits intomaster from
feature/delay

Conversation

@Jakubk15
Copy link
Member

@Jakubk15 Jakubk15 commented Feb 7, 2026

Delay classes are used commonly in our other projects, so now they will be in EternalCodeCommons.

Copy link
Contributor

Summary of Changes

Hello @Jakubk15, I'm Gemini Code Assist1 ! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a robust and generic delay management system into the EternalCodeCommons library. By leveraging the Caffeine caching library, it provides an efficient way to track and manage time-based delays for any type of object, centralizing a common pattern previously implemented across various projects. This addition aims to streamline delay-related logic and improve code reusability within the ecosystem.

Highlights

  • New Delay Utility Class: Implemented a new generic Delay<T> utility class to manage time-based delays for various objects, providing methods to mark, unmark, check, and get remaining time for delays.
  • Caffeine Cache Integration: Integrated the Caffeine high-performance caching library to efficiently store and manage delay expiration times, ensuring optimal performance for delay tracking.
  • Custom Instant-based Expiry: Introduced a custom InstantExpiry class that implements Caffeine's Expiry interface, allowing cache entries to expire precisely based on java.time.Instant objects.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • eternalcode-commons-shared/build.gradle.kts
    • Added com.github.ben-manes.caffeine:caffeine:3.2.3 as an implementation dependency to the project.
  • eternalcode-commons-shared/src/main/java/com/eternalcode/commons/delay/Delay.java
    • New class Delay<T> created, offering functionalities to set, check, and remove delays for generic keys.
    • Utilizes a Caffeine cache internally, configured with a custom expiry mechanism for Instant values.
  • eternalcode-commons-shared/src/main/java/com/eternalcode/commons/delay/InstantExpiry.java
    • New class InstantExpiry<T> added, implementing Expiry<T, Instant> for Caffeine cache.
    • Provides custom logic to calculate expiration times based on Instant objects, ensuring accurate time-based invalidation of cache entries.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@Jakubk15 Jakubk15 changed the title (削除) Add delay (削除ここまで) (追記) GH-76 Add delay (追記ここまで) Feb 7, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a reusable Delay class. However, the Delay utility class, which uses the Caffeine caching library, has two medium-severity Denial of Service (DoS) vulnerabilities. These include an unbounded cache that could lead to memory exhaustion and an ArithmeticException in the expiration calculation logic due to unhandled overflow in Duration.toNanos() for durations exceeding 292 years. It is recommended to set a maximum cache size and add overflow protection for duration conversions. Furthermore, a critical issue in build.gradle.kts uses a non-existent dependency version, which will cause the build to fail. Lastly, improvements are needed in the Delay class for a logic issue in markDelay with non-positive durations, a performance opportunity in getExpireAt, and an API usability enhancement for getRemaining.

Comment on lines +21 to +23
this.cache = Caffeine.newBuilder()
.expireAfter(new InstantExpiry<T>())
.build();
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-medium medium

The Caffeine cache is initialized without a maximum size, which can lead to memory exhaustion if a large number of unique keys are added. This is especially risky if the keys are derived from untrusted user input (e.g., unique user IDs or IP addresses). Adding a limit prevents the cache from growing indefinitely.

 this.cache = Caffeine.newBuilder()
 .expireAfter(new InstantExpiry<T>())
 .maximumSize(1000) // TODO: Adjust this value based on expected usage
 .build();

Copy link
Member Author

@Jakubk15 Jakubk15 Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this will affect our use-cases

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

Reviewers

@CitralFlo CitralFlo Awaiting requested review from CitralFlo

@imDMK imDMK Awaiting requested review from imDMK

@noyzys noyzys Awaiting requested review from noyzys

@vLuckyyy vLuckyyy Awaiting requested review from vLuckyyy

1 more reviewer

@gemini-code-assist gemini-code-assist[bot] gemini-code-assist[bot] left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /