Commit dd12700
Cherry-pick in-memory cache implementation for release 23.1.1 Fixes AB#3444129 (#2822)
Fixes
[AB#3444129](https://identitydivision.visualstudio.com/fac9d424-53d2-45c0-91b5-ef6ba7a6bf26/_workitems/edit/3444129)
Cherry-picks two commits from dev to enable in-memory caching for
accounts and credentials in the broker.
## Commits
- **f904c60** - Use in-memory cache for accounts and credentials
([AB#3417272](https://identitydivision.visualstudio.com/fac9d424-53d2-45c0-91b5-ef6ba7a6bf26/_workitems/edit/3417272),
#2802)
- **228db78** - Share SharedPreferencesInMemoryCache across cache
instances
([AB#3428107](https://identitydivision.visualstudio.com/fac9d424-53d2-45c0-91b5-ef6ba7a6bf26/_workitems/edit/3428107),
#2813)
## Changes
**Core Implementation** (`BrokerOAuth2TokenCache.java`)
- Added static `ConcurrentHashMap` to share in-memory cache instances
across `BrokerOAuth2TokenCache` instances
- Reduces disk I/O and serialization overhead by reusing cache layers
for the same underlying storage
**Feature Flag** (`CommonFlight.java`)
- Added `USE_IN_MEMORY_CACHE_FOR_ACCOUNTS_AND_CREDENTIALS` (default:
false)
**Telemetry** (`AttributeName.java`)
- Added `in_memory_cache_used_for_accounts_and_credentials` attribute
**Tests**
- New `BrokerOAuth2TokenCacheWithInMemoryCacheTest.java` (1240 lines)
- Extended `BrokerOAuth2TokenCacheTest.java` with cache sharing tests
## Conflicts Resolved
`changelog.txt` had conflicts due to version markers in the release
branch. Resolved by adding entries under vNext:
```
- [MINOR] Share SharedPreferencesInMemoryCache across instances of BrokerOAuth2TokenCache (#2813)
- [MINOR] Use SharedPreferencesInMemoryCache implementation in Broker (#2802)
```
> [!WARNING]
>
> <details>
> <summary>Firewall rules blocked me from connecting to one or more
addresses (expand for details)</summary>
>
> #### I tried to connect to the following addresses, but was blocked by
firewall rules:
>
> - `dl.google.com`
> - Triggering command: `/usr/lib/jvm/temurin-17-jdk-amd64/bin/java
/usr/lib/jvm/temurin-17-jdk-amd64/bin/java
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED
--add-opens=java.base/java.nio.charset=ALL-UNNAMED
--add-opens=java.base/java.net=ALL-UNNAMED
--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED
--add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED
-XX:MaxMetaspaceSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Xmx3072m
-Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant`
(dns block)
> - `www.puppycrawl.com`
> - Triggering command:
`/opt/hostedtoolcache/CodeQL/2.23.3/x64/codeql/tools/linux64/java/bin/java
/opt/hostedtoolcache/CodeQL/2.23.3/x64/codeql/tools/linux64/java/bin/java
-jar
/opt/hostedtoolcache/CodeQL/2.23.3/x64/codeql/xml/tools/xml-extractor.jar
--fileList=/home/REDACTED/work/microsoft-authentication-library-common-for-android/.codeql-scratch/dbs/java/working/files-to-index2294403091429273239.list
--sourceArchiveDir=/home/REDACTED/work/microsoft-authentication-library-common-for-android/.codeql-scratch/dbs/java/src
--outputDir=/home/REDACTED/work/microsoft-authentication-library-common-for-android/.codeql-scratch/dbs/java/trap/java`
(dns block)
>
> If you need me to access, download, or install something from one of
these locations, you can either:
>
> - Configure [Actions setup
steps](https://gh.io/copilot/actions-setup-steps) to set up my
environment, which run before the firewall is enabled
> - Add the appropriate URLs or hosts to the custom allowlist in this
repository's [Copilot coding agent
settings](https://github.com/AzureAD/microsoft-authentication-library-common-for-android/settings/copilot/coding_agent)
(admins only)
>
> </details>
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
> Cherry-pick the following commits from the dev branch to the
working/release/23.1.1 branch:
>
> - f904c60
> - 228db78
>
> Include all files and changes from the specified commits. Ensure that
any conflicts are noted in the pull request description. Provide a
detailed summary of what was cherry-picked in the PR body.
</details>
*This pull request was created as a result of the following prompt from
Copilot chat.*
> Cherry-pick the following commits from the dev branch to the
working/release/23.1.1 branch:
>
> - f904c60
> - 228db78
>
> Include all files and changes from the specified commits. Ensure that
any conflicts are noted in the pull request description. Provide a
detailed summary of what was cherry-picked in the PR body.
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: siddhijain <[email protected]>
Co-authored-by: Siddhi <[email protected]>1 parent a15adf5 commit dd12700
File tree
6 files changed
+1459
-79
lines changed- common4j/src/main/com/microsoft/identity/common/java
- cache
- flighting
- opentelemetry
- common/src/test/java/com/microsoft/identity/common
6 files changed
+1459
-79
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
| |||
1199 | 1198 | | |
1200 | 1199 | | |
1201 | 1200 | | |
1202 | | - | |
| 1201 | + | |
Lines changed: 127 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
50 | | - | |
51 | 52 | | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | | - | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| 70 | + | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
73 | 79 | | |
74 | 80 | | |
75 | 81 | | |
| |||
79 | 85 | | |
80 | 86 | | |
81 | 87 | | |
| 88 | + | |
82 | 89 | | |
83 | 90 | | |
84 | 91 | | |
85 | 92 | | |
| 93 | + | |
86 | 94 | | |
87 | 95 | | |
88 | 96 | | |
89 | | - | |
90 | 97 | | |
91 | 98 | | |
92 | 99 | | |
| |||
236 | 243 | | |
237 | 244 | | |
238 | 245 | | |
| 246 | + | |
239 | 247 | | |
240 | 248 | | |
241 | 249 | | |
| |||
1241 | 1249 | | |
1242 | 1250 | | |
1243 | 1251 | | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
1244 | 1368 | | |
0 commit comments