Skip to content

Commit 56cf12d

Browse files
chore: add Spotless and Prettier action, format files
1 parent 498b441 commit 56cf12d

File tree

20 files changed

+300
-244
lines changed

20 files changed

+300
-244
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
22
name: Bug report
33
about: Create a report to help us improve
4-
title: ''
4+
title: ""
55
labels: bug
6-
assignees: ''
7-
6+
assignees: ""
87
---
98

109
**Describe the bug**
1110

1211
**To Reproduce**
1312
Steps to reproduce:
14-
1.
13+
14+
1.
1515

1616
**Expected behavior**
1717

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
---
22
name: Feature request
33
about: Suggest an idea for this project
4-
title: ''
4+
title: ""
55
labels: enhancement
6-
assignees: ''
7-
6+
assignees: ""
87
---
9-
10-

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
*Issue #, if available:*
2-
3-
*Description of changes:*
1+
_Issue #, if available:_
42

3+
_Description of changes:_
54

65
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

.github/workflows/codeql-analysis.yml

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ name: "CodeQL"
1313

1414
on:
1515
push:
16-
branches: [ "master", "v2" ]
16+
branches: ["master", "v2"]
1717
pull_request:
1818
# The branches below must be a subset of the branches above
19-
branches: [ "master", "v2" ]
19+
branches: ["master", "v2"]
2020
schedule:
21-
- cron: '17 12 * * 1'
21+
- cron: "17 12 * * 1"
2222

2323
jobs:
2424
analyze:
@@ -30,41 +30,40 @@ jobs:
3030
strategy:
3131
fail-fast: true
3232
matrix:
33-
language: [ 'java' ]
33+
language: ["java"]
3434
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
3535
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
3636

3737
steps:
38-
- name: Checkout repository
39-
uses: actions/checkout@v4
38+
- name: Checkout repository
39+
uses: actions/checkout@v4
4040

41-
# Initializes the CodeQL tools for scanning.
42-
- name: Initialize CodeQL
43-
uses: github/codeql-action/init@v3
44-
with:
45-
languages: ${{ matrix.language }}
46-
# If you wish to specify custom queries, you can do so here or in a config file.
47-
# By default, queries listed here will override any specified in a config file.
48-
# Prefix the list here with "+" to use these queries and those in the config file.
49-
50-
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
51-
# queries: security-extended,security-and-quality
41+
# Initializes the CodeQL tools for scanning.
42+
- name: Initialize CodeQL
43+
uses: github/codeql-action/init@v3
44+
with:
45+
languages: ${{ matrix.language }}
46+
# If you wish to specify custom queries, you can do so here or in a config file.
47+
# By default, queries listed here will override any specified in a config file.
48+
# Prefix the list here with "+" to use these queries and those in the config file.
5249

53-
54-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55-
# If this step fails, then you should remove it and run the build manually (see below)
56-
- name: Autobuild
57-
uses: github/codeql-action/autobuild@v3
50+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
51+
# queries: security-extended,security-and-quality
5852

59-
# ℹ️ Command-line programs to run using the OS shell.
60-
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
53+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54+
# If this step fails, then you should remove it and run the build manually (see below)
55+
- name: Autobuild
56+
uses: github/codeql-action/autobuild@v3
6157

62-
# If the Autobuild fails above, remove it and uncomment the following three lines.
63-
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
58+
# ℹ️ Command-line programs to run using the OS shell.
59+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
6460

65-
# - run: |
66-
# echo "Run, Build Application using script"
67-
# ./location_of_script_within_repo/buildscript.sh
61+
# If the Autobuild fails above, remove it and uncomment the following three lines.
62+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
6863

69-
- name: Perform CodeQL Analysis
70-
uses: github/codeql-action/analyze@v3
64+
# - run: |
65+
# echo "Run, Build Application using script"
66+
# ./location_of_script_within_repo/buildscript.sh
67+
68+
- name: Perform CodeQL Analysis
69+
uses: github/codeql-action/analyze@v3

.github/workflows/maven.yml

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,39 @@
44
name: Java CI with Maven
55

66
on:
7-
push:
8-
branches: [ "master", "v2" ]
97
pull_request:
10-
branches: [ "master", "v2" ]
8+
branches: [master, v2]
119

1210
jobs:
1311
build:
14-
1512
runs-on: ubuntu-latest
1613

1714
steps:
18-
- uses: actions/checkout@v4
19-
- name: Set up JDK 21
20-
uses: actions/setup-java@v4
21-
with:
22-
java-version: '21'
23-
distribution: 'corretto'
24-
cache: maven
25-
- name: Maven version
26-
run: mvn --version
27-
- name: Build with Maven
28-
run: mvn clean package
29-
- name: Codecov
30-
uses: codecov/[email protected]
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Set up JDK 21
19+
uses: actions/setup-java@v4
20+
with:
21+
java-version: 21
22+
distribution: corretto
23+
cache: mave
24+
25+
- name: Prettier
26+
uses: rutajdash/[email protected]
27+
with:
28+
file_pattern: "**/*.{md,yml}"
29+
30+
- name: Check formatting
31+
run: mvn spotless:check
32+
33+
- name: Maven version
34+
run: mvn --version
35+
36+
- name: Build with Maven
37+
run: mvn clean package
38+
39+
- name: Codecov
40+
uses: codecov/codecov-action@v5
41+
with:
42+
token: ${{ secrets.CODECOV_TOKEN }}

CODE_OF_CONDUCT.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
## Code of Conduct
2-
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3-
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
2+
3+
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
4+
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
45
[email protected] with any additional questions or comments.

CONTRIBUTING.md

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,63 @@
11
# Contributing Guidelines
22

3-
Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
3+
Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
44
documentation, we greatly value feedback and contributions from our community.
55

6-
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
6+
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
77
information to effectively respond to your bug report or contribution.
88

9-
109
## Reporting Bugs/Feature Requests
1110

1211
We welcome you to use the GitHub issue tracker to report bugs or suggest features.
1312

14-
When filing an issue, please check [existing open](https://github.com/aws/aws-secretsmanager-caching-java/issues), or [recently closed](https://github.com/aws/aws-secretsmanager-caching-java/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already
13+
When filing an issue, please check [existing open](https://github.com/aws/aws-secretsmanager-caching-java/issues), or [recently closed](https://github.com/aws/aws-secretsmanager-caching-java/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already
1514
reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
1615

17-
* A reproducible test case or series of steps
18-
* The version of our code being used
19-
* Any modifications you've made relevant to the bug
20-
* Anything unusual about your environment or deployment
21-
16+
- A reproducible test case or series of steps
17+
- The version of our code being used
18+
- Any modifications you've made relevant to the bug
19+
- Anything unusual about your environment or deployment
2220

2321
## Contributing via Pull Requests
22+
2423
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
2524

26-
1. You are working against the latest source on the *master* branch.
25+
1. You are working against the latest source on the _master_ branch.
2726
2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
2827
3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
2928

3029
To send us a pull request, please:
3130

3231
1. Fork the repository.
3332
2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
34-
3. Ensure local tests pass.
35-
4. Commit to your fork using clear commit messages.
36-
5. Send us a pull request, answering any default questions in the pull request interface.
37-
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
33+
3. Use Spotless to ensure consistent formatting for `.java` files, and Prettier for `.md` and `.yml` files (see [Formatting instructions](#formatting-instructions)).
34+
4. Ensure local tests pass.
35+
5. Commit to your fork using clear commit messages.
36+
6. Send us a pull request, answering any default questions in the pull request interface.
37+
7. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
3838

39-
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
39+
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
4040
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
4141

42+
# Formatting instructions
43+
44+
- Install [Prettier](https://prettier.io/docs/install).
45+
- If using VS Code, install the VS Code extension for the above.
46+
- Run `mvn spotless:apply` and `prettier --write **/*.{md,yml}`.
4247

4348
## Finding contributions to work on
44-
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/aws/aws-secretsmanager-caching-java/labels/help%20wanted) issues is a great place to start.
4549

50+
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/aws/aws-secretsmanager-caching-java/labels/help%20wanted) issues is a great place to start.
4651

4752
## Code of Conduct
48-
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
49-
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
50-
[email protected] with any additional questions or comments.
5153

54+
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
55+
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
56+
[email protected] with any additional questions or comments.
5257

5358
## Security issue notifications
54-
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
5559

60+
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
5661

5762
## Licensing
5863

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ The AWS Secrets Manager Java caching client enables in-process caching of secret
88
## Getting Started
99

1010
### Required Prerequisites
11+
1112
To use this client you must have:
1213

13-
* **A Java 8 development environment**
14+
- **A Java 8 development environment**
1415

1516
If you do not have one, go to [Java SE Downloads](https://www.oracle.com/technetwork/java/javase/downloads/index.html) on the Oracle website, then download and install the Java SE Development Kit (JDK). Java 8 or higher is recommended.
1617

1718
An Amazon Web Services (AWS) account to access secrets stored in AWS Secrets Manager and use AWS SDK for Java.
1819

19-
* **To create an AWS account**, go to [Sign In or Create an AWS Account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) and then choose **I am a new user.** Follow the instructions to create an AWS account.
20+
- **To create an AWS account**, go to [Sign In or Create an AWS Account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) and then choose **I am a new user.** Follow the instructions to create an AWS account.
2021

21-
* **To create a secret in AWS Secrets Manager**, go to [Creating Secrets](https://docs.aws.amazon.com/secretsmanager/latest/userguide/manage_create-basic-secret.html) and follow the instructions on that page.
22+
- **To create a secret in AWS Secrets Manager**, go to [Creating Secrets](https://docs.aws.amazon.com/secretsmanager/latest/userguide/manage_create-basic-secret.html) and follow the instructions on that page.
2223

23-
* **To download and install the AWS SDK for Java**, go to [Installing the AWS SDK for Java](https://docs.aws.amazon.com/AWSSdkDocsJava/latest/DeveloperGuide/java-dg-install-sdk.html) in the AWS SDK for Java documentation and then follow the instructions on that page.
24+
- **To download and install the AWS SDK for Java**, go to [Installing the AWS SDK for Java](https://docs.aws.amazon.com/AWSSdkDocsJava/latest/DeveloperGuide/java-dg-install-sdk.html) in the AWS SDK for Java documentation and then follow the instructions on that page.
2425

2526
### Download
2627

@@ -90,4 +91,4 @@ public class SampleClass implements RequestHandler<String, String> {
9091

9192
## License
9293

93-
This library is licensed under the Apache 2.0 License.
94+
This library is licensed under the Apache 2.0 License.

pom.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,20 @@
189189
<argLine>@{argLine} -javaagent:${org.mockito:mockito-core:jar}</argLine>
190190
</configuration>
191191
</plugin>
192+
<plugin>
193+
<groupId>com.diffplug.spotless</groupId>
194+
<artifactId>spotless-maven-plugin</artifactId>
195+
<version>2.44.4</version>
196+
<configuration>
197+
<!-- define a language-specific format -->
198+
<java>
199+
<palantirJavaFormat>
200+
<version>2.39.0</version>
201+
<style>PALANTIR</style>
202+
</palantirJavaFormat>
203+
</java>
204+
</configuration>
205+
</plugin>
192206
</plugins>
193207
</build>
194208

@@ -224,4 +238,4 @@
224238
</build>
225239
</profile>
226240
</profiles>
227-
</project>
241+
</project>

src/main/java/com/amazonaws/secretsmanager/caching/SecretCache.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212
*/
1313
package com.amazonaws.secretsmanager.caching;
1414

15-
import java.nio.ByteBuffer;
16-
1715
import com.amazonaws.secretsmanager.caching.cache.LRUCache;
1816
import com.amazonaws.secretsmanager.caching.cache.SecretCacheItem;
1917
import com.amazonaws.secretsmanager.caching.cache.internal.VersionInfo;
20-
18+
import java.nio.ByteBuffer;
2119
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
2220
import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption;
2321
import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient;
@@ -70,12 +68,11 @@ public SecretCache() {
7068
* client.
7169
*/
7270
public SecretCache(SecretsManagerClientBuilder builder) {
73-
this(new SecretCacheConfiguration().withClient(builder
74-
.overrideConfiguration(
75-
builder.overrideConfiguration().toBuilder()
71+
this(new SecretCacheConfiguration()
72+
.withClient(builder.overrideConfiguration(builder.overrideConfiguration().toBuilder()
7673
.putAdvancedOption(SdkAdvancedClientOption.USER_AGENT_SUFFIX, VersionInfo.USER_AGENT)
7774
.build())
78-
.build()));
75+
.build()));
7976
}
8077

8178
/**
@@ -100,9 +97,13 @@ public SecretCache(SecretCacheConfiguration config) {
10097
this.cache = new LRUCache<String, SecretCacheItem>(config.getMaxCacheSize());
10198
this.config = config;
10299
ClientOverrideConfiguration defaultOverride = ClientOverrideConfiguration.builder()
103-
.putAdvancedOption(SdkAdvancedClientOption.USER_AGENT_SUFFIX, VersionInfo.USER_AGENT).build();
104-
this.client = config.getClient() != null ? config.getClient()
105-
: SecretsManagerClient.builder().overrideConfiguration(defaultOverride).build();
100+
.putAdvancedOption(SdkAdvancedClientOption.USER_AGENT_SUFFIX, VersionInfo.USER_AGENT)
101+
.build();
102+
this.client = config.getClient() != null
103+
? config.getClient()
104+
: SecretsManagerClient.builder()
105+
.overrideConfiguration(defaultOverride)
106+
.build();
106107
}
107108

108109
/**
@@ -114,8 +115,7 @@ public SecretCache(SecretCacheConfiguration config) {
114115
private SecretCacheItem getCachedSecret(final String secretId) {
115116
SecretCacheItem secret = this.cache.get(secretId);
116117
if (null == secret) {
117-
this.cache.putIfAbsent(secretId,
118-
new SecretCacheItem(secretId, this.client, this.config));
118+
this.cache.putIfAbsent(secretId, new SecretCacheItem(secretId, this.client, this.config));
119119
secret = this.cache.get(secretId);
120120
}
121121
return secret;
@@ -171,5 +171,4 @@ public boolean refreshNow(final String secretId) throws InterruptedException {
171171
public void close() {
172172
this.cache.clear();
173173
}
174-
175174
}

0 commit comments

Comments
 (0)