Repository navigation
feat: cache plugin manifest files with bbb-web - #24220
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds an optional, date-based plugin-manifest caching layer and wires it into meeting creation. MeetingService gains injectable fields and setters for Sequence Diagram(s)sequenceDiagram
participant Client
participant MeetingService
participant PluginUtils
participant FileSystem
participant ExternalURL
rect rgba(232,245,233,0.5)
Note over MeetingService,PluginUtils: Cache-enabled conditional flow
end
Client->>MeetingService: Create meeting (with plugin manifests)
MeetingService->>PluginUtils: getRawPluginManifestContent(manifest)
PluginUtils->>PluginUtils: obtain per-URL lock
alt Cache enabled -> check cache
PluginUtils->>FileSystem: Read cached manifest (date-hashed path)
alt Cache hit
FileSystem-->>PluginUtils: cached content
else Cache miss
FileSystem-->>PluginUtils: null
PluginUtils->>ExternalURL: HTTP GET manifest
ExternalURL-->>PluginUtils: manifest content
PluginUtils->>PluginUtils: validate checksum & parse name
PluginUtils->>FileSystem: write cached manifest (if valid)
end
else Cache disabled
PluginUtils->>ExternalURL: HTTP GET manifest
ExternalURL-->>PluginUtils: manifest content
end
PluginUtils-->>MeetingService: pluginManifestContent
MeetingService->>MeetingService: parse JSON, verify name/checksum, substitute template
MeetingService-->>Client: Return meeting creation response
rect rgba(255,235,238,0.5)
Note over FileSystem: Daily cleanup job removes /var/bigbluebutton/plugin-manifests-cache/
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java(5 hunks)bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java(3 hunks)bigbluebutton-config/cron.daily/bigbluebutton(1 hunks)bigbluebutton-web/grails-app/conf/bigbluebutton.properties(1 hunks)bigbluebutton-web/grails-app/conf/spring/resources.xml(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java (1)
bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java (1)
PluginUtils(29-239)
bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java (2)
bbb-common-web/src/main/java/org/bigbluebutton/api/ParamsProcessorUtil.java (1)
ParamsProcessorUtil(49-1835)bbb-common-web/src/main/java/org/bigbluebutton/api/domain/PluginManifest.java (1)
PluginManifest(3-32)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build-package (bbb-web)
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java (1)
381-441: Handle race condition in placeholder file creation.When two threads simultaneously experience a cache miss for the same plugin URL, both will attempt to call
createEmptyCacheFileFromat line 386. The second thread's call will throwFileAlreadyExistsException(caught asIOExceptionat line 453), causing the plugin to fail with a misleading "I/O error" message instead of gracefully handling the race condition.Modify
PluginUtils.createEmptyCacheFileFrom(lines 195-200) to catch and suppressFileAlreadyExistsException, since the placeholder already exists and serves its purpose—preventing duplicate fetches.
♻️ Duplicate comments (1)
bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java (1)
195-200: Handle race condition in placeholder creation.This is similar to the past review comment. When two threads simultaneously experience a cache miss for the same plugin, both will invoke
createEmptyCacheFileFrom. The second call will hitFileAlreadyExistsExceptionat line 199, causing the entire manifest fetch to fail inMeetingService.Apply this diff to tolerate concurrent placeholder creation:
+import java.nio.file.FileAlreadyExistsException; + public static void createEmptyCacheFileFrom(String pluginManifestUrlString) throws IOException { Path cachedPluginManifestPath = getCachedPluginManifestPath(pluginManifestUrlString); Path cacheDir = getCachedPluginsBaseDirectory(); Files.createDirectories(cacheDir); - Files.createFile(cachedPluginManifestPath); + try { + Files.createFile(cachedPluginManifestPath); + } catch (FileAlreadyExistsException e) { + // Another thread already created the placeholder; that's fine + } }
🧹 Nitpick comments (2)
bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java (1)
21-21: Prefer explicit imports over wildcard.Wildcard imports obscure which classes are actually used and can lead to naming conflicts.
Replace the wildcard with explicit imports:
-import java.io.*; +import java.io.IOException;bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java (1)
225-232: Reuse the directory helper method.Line 230 creates a new
Pathfrom the constant, but you already havegetCachedPluginsBaseDirectory()for this purpose.Apply this diff:
public static Path getCachedPluginManifestPath(String pluginManifestUrlString) { LocalDate date = LocalDate.now(); String formatted = date.format(formatter); String hashedPluginManifestUrl = DigestUtils.sha256Hex(pluginManifestUrlString + formatted); - Path cacheDir = Paths.get(CACHED_PLUGINS_BASE_DIRECTORY); + Path cacheDir = getCachedPluginsBaseDirectory(); return cacheDir.resolve(hashedPluginManifestUrl + ".json"); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java(5 hunks)bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java (2)
bbb-common-web/src/main/java/org/bigbluebutton/api/ParamsProcessorUtil.java (1)
ParamsProcessorUtil(49-1835)bbb-common-web/src/main/java/org/bigbluebutton/api/domain/PluginManifest.java (1)
PluginManifest(3-32)
bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java (1)
bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java (1)
PluginUtils(29-241)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build-package (bbb-web)
🔇 Additional comments (4)
bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java (1)
1602-1604: Setter looks correct.The setter follows standard conventions. If you change the field to primitive
booleanper the earlier comment, update this parameter to match or explicitly handlenull(e.g., treat asfalse).bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java (3)
180-193: Cache read logic is sound.The method correctly checks for file existence before reading and returns
nullon cache miss. The TOCTOU gap between the existence check and read is acceptable since the caller handlesIOException.
202-210: Concurrent writes are acceptable.If multiple threads fetch and save the same manifest, both
writeStringcalls will succeed; the last writer wins. Since they're writing identical content, this is safe.
221-223: Helper method is straightforward.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
bigbluebutton-config/cron.daily/bigbluebutton (1)
147-147: Consider adding a configuration option for flexibility.The unconditional invocation is reasonable for a date-based cache cleanup. However, following the pattern of
remove_raw_of_recordings_without_marks(lines 87-88), you might consider adding a comment noting that this can be disabled if needed, or introduce a config variable for this cleanup task.Example (similar to line 88):
+# Enabled by default; comment to disable. remove_plugin_manifests_cache
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java(5 hunks)bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java(3 hunks)bigbluebutton-config/cron.daily/bigbluebutton(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java
- bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build-package (bbb-web)
🔇 Additional comments (1)
bigbluebutton-config/cron.daily/bigbluebutton (1)
139-145: LGTM! Implementation addresses previous feedback.The function correctly removes the entire cache directory (as suggested in the past review comment), includes a proper existence check, and follows the established cleanup patterns in this file. The logging provides good visibility, and the quoted variable prevents potential issues with word splitting.
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (2)
bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java (2)
40-40: Make cache directory constant immutable.This issue was previously flagged:
CACHED_PLUGINS_BASE_DIRECTORYshould be declared aspublic static final Stringto prevent runtime modification.Apply this diff:
-public static String CACHED_PLUGINS_BASE_DIRECTORY = "/var/bigbluebutton/plugin-manifests-cache/"; +public static final String CACHED_PLUGINS_BASE_DIRECTORY = "/var/bigbluebutton/plugin-manifests-cache/";
220-227: Check HTTP status code before returning body.This issue was previously flagged: the method returns the response body for any HTTP status, including error responses (404, 500, etc.), which can lead to parsing failures.
Apply this diff to validate the response:
public static String fetchPluginManifestContentFromUrl( String pluginManifestUrlString ) throws IOException, InterruptedException { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder(URI.create(pluginManifestUrlString)).GET().build(); HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString()); + if (response.statusCode() < 200 || response.statusCode() >= 300) { + throw new IOException("HTTP " + response.statusCode() + " when fetching " + pluginManifestUrlString); + } return response.body(); }
🧹 Nitpick comments (4)
bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java (4)
204-206: Optimize cache existence check to avoid reading file content.Currently, this method reads the entire cached file just to verify existence. For large manifests, this is wasteful when only a boolean check is needed.
Apply this diff to check existence without reading content:
public static boolean hasPluginManifestContentCacheFile(String pluginManifestUrlString) throws IOException { - return getPluginManifestContentFromCache(pluginManifestUrlString) != null; + synchronized (getLockFor(pluginManifestUrlString)) { + Path cachedPluginManifestPath = getCachedPluginManifestPath(pluginManifestUrlString); + return Files.isRegularFile(cachedPluginManifestPath); + } }
233-240: UsegetCachedPluginsBaseDirectory()for consistency.Line 238 duplicates the path construction logic that's already available in
getCachedPluginsBaseDirectory().Apply this diff:
public static Path getCachedPluginManifestPath(String pluginManifestUrlString) { LocalDate date = LocalDate.now(); String formatted = date.format(formatter); String hashedPluginManifestUrl = DigestUtils.sha256Hex(pluginManifestUrlString + formatted); - Path cacheDir = Paths.get(CACHED_PLUGINS_BASE_DIRECTORY); + Path cacheDir = getCachedPluginsBaseDirectory(); return cacheDir.resolve(hashedPluginManifestUrl + ".json"); }
220-227: Configure HTTP timeouts to prevent thread exhaustion.The
HttpClientis created without timeout configuration. If a plugin manifest server is slow or unresponsive, threads will block indefinitely.Apply this diff to add sensible timeouts:
+import java.time.Duration; + public static String fetchPluginManifestContentFromUrl( String pluginManifestUrlString ) throws IOException, InterruptedException { - HttpClient client = HttpClient.newHttpClient(); - HttpRequest request = HttpRequest.newBuilder(URI.create(pluginManifestUrlString)).GET().build(); + HttpClient client = HttpClient.newBuilder() + .connectTimeout(Duration.ofSeconds(10)) + .build(); + HttpRequest request = HttpRequest.newBuilder(URI.create(pluginManifestUrlString)) + .GET() + .timeout(Duration.ofSeconds(30)) + .build(); HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() < 200 || response.statusCode() >= 300) { throw new IOException("HTTP " + response.statusCode() + " when fetching " + pluginManifestUrlString); } return response.body(); }
208-218: Consider adding size limits when writing cached manifests.Currently, there's no limit on the size of cached content. A malicious or misconfigured plugin could provide a very large "manifest" that fills disk space.
Reference the
maxPluginManifestsFetchUrlPayloadSizepattern used inParamsProcessorUtil.processPluginManifestsFetchUrl(see relevant code snippets) to validate manifest size before caching. Consider adding a configuration property for the maximum cached manifest size and checking content length before writing.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java (2)
bbb-common-web/src/main/java/org/bigbluebutton/api/ParamsProcessorUtil.java (1)
ParamsProcessorUtil(49-1835)bbb-common-web/src/main/java/org/bigbluebutton/api/domain/PluginManifest.java (1)
PluginManifest(3-32)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build-package (bbb-web)
🔇 Additional comments (3)
bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java (3)
41-46: LGTM: Thread-safe per-URL locking.The date formatter and per-URL lock mechanism using
ConcurrentHashMap.computeIfAbsentprovide thread-safe cache operations without global contention.
187-202: LGTM: Cache retrieval is thread-safe and handles misses correctly.The synchronized block, regular-file check, and null-on-miss pattern are all appropriate.
208-218: LGTM: Cache write properly creates directories and handles overwrites.The synchronized block, directory creation, and atomic write operation are correct.
Files.createDirectoriesis idempotent, and overwriting existing cache entries is the expected behavior.
|
|
This pull request has conflicts ☹ |
gustavotrott
left a comment
There was a problem hiding this comment.
It's working properly. But I left a few suggestions.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (3)
bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java (2)
238-245: Validate HTTP status codes before returning manifest body
fetchPluginManifestContentFromUrlcurrently returns the response body for any HTTP status. If the server responds with 404/500 (HTML error page, maintenance message, etc.), the caller attempts to parse it as JSON and only later fails, which makes errors less clear and may complicate debugging.Consider checking
response.statusCode()and treating non-2xx as an I/O error:HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder(URI.create(pluginManifestUrlString)).GET().build(); HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString()); - return response.body(); + int status = response.statusCode(); + if (status < 200 || status >= 300) { + throw new IOException("HTTP " + status + " when fetching " + pluginManifestUrlString); + } + return response.body();This allows the caller to surface a clearer error path for HTTP failures instead of a downstream JSON parse error.
5-5: MD5 is sufficient (and faster) for cache file namingFor
getCachedPluginManifestPath, the hash is only used to derive a filesystem-friendly name, not for security or integrity. UsingDigestUtils.sha256Hex(...)is stronger than necessary and slightly more expensive.Switching to MD5 keeps collision risk negligible in this context and reduces cost:
- String hashedPluginManifestUrl = DigestUtils.sha256Hex(pluginManifestUrlString + formatted); + String hashedPluginManifestUrl = DigestUtils.md5Hex(pluginManifestUrlString + formatted);Since this only affects opaque filenames in the cache directory, the change is internal and doesn’t alter behavior from the caller’s perspective.
Also applies to: 255-257
bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java (1)
90-90: AvoidNullPointerExceptiononpluginManifestCacheEnabledand prefer primitive boolean
pluginManifestCacheEnabledis a boxedBooleanand used directly in conditionals (e.g., Line 382:if (pluginManifestCacheEnabled) {), which will NPE if the property is not set or injected asnull. Given this is a feature flag, defaulting tofalseis safer and more explicit.Consider switching to a primitive with a safe default and updating the setter accordingly:
- private Boolean pluginManifestCacheEnabled; + private boolean pluginManifestCacheEnabled = false; ... - public void setPluginManifestCacheEnabled(Boolean pluginManifestCacheEnabled) { - this.pluginManifestCacheEnabled = pluginManifestCacheEnabled; - } + public void setPluginManifestCacheEnabled(boolean pluginManifestCacheEnabled) { + this.pluginManifestCacheEnabled = pluginManifestCacheEnabled; + }This keeps the call sites simple and removes the risk of an unexpected NPE during manifest fetching.
Also applies to: 381-387, 1601-1603
🧹 Nitpick comments (1)
bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java (1)
44-50: Cache coordination mostly solid; consider lighter existence checks and single check+save pathThe per-URL locking and date-based hash path generation look good, but a couple of details can be streamlined:
hasPluginManifestContentCacheFile(...)callsgetPluginManifestContentFromCache(...), which reads the entire file into memory just to check existence. For large numbers of requests this is unnecessary overhead.- The existence check (
has...) and write (save...) are done in separate calls; under concurrency, two threads can both see a miss and both write the same file. It’s safe, but wasteful.You could simplify and make this more efficient by:
- Letting
hasPluginManifestContentCacheFilejust check for existence under the per-URL lock without reading content:public static boolean hasPluginManifestContentCacheFile(String pluginManifestUrlString) throws IOException { synchronized (getLockFor(pluginManifestUrlString)) { Path cachedPluginManifestPath = getCachedPluginManifestPath(pluginManifestUrlString); return Files.isRegularFile(cachedPluginManifestPath); } }
- Or even better, moving the existence check inside
savePluginManifestContentInCache(still under the same lock) so callers simply say “save” and the method no-ops when the file already exists.This keeps the locking model simple, avoids redundant file reads, and further reduces the chance of duplicate writes.
Also applies to: 205-236, 247-258
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java(5 hunks)bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java (3)
bbb-common-web/src/main/java/org/bigbluebutton/api/domain/PluginManifest.java (1)
PluginManifest(3-32)bbb-common-web/src/main/java/org/bigbluebutton/api/exception/PluginMalformedParametersException.java (1)
PluginMalformedParametersException(5-27)bbb-common-web/src/main/java/org/bigbluebutton/api/exception/PluginMetadataException.java (1)
PluginMetadataException(3-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build-package (bbb-html5)
- GitHub Check: build-package (bbb-web)
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (1)
bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java (1)
227-235: Consider an atomic cache write.
Files.writeStringwrites in place. If the JVM crashes mid-write, a truncated or partial JSON file remains and will be served on the next request (the read path doesn't re-validate cached content against the checksum before returning). Writing to a sibling temp file and usingFiles.move(..., ATOMIC_MOVE, REPLACE_EXISTING)avoids torn writes and concurrent reader/writer interleavings on platforms that support it.♻️ Proposed sketch
- Path cachedPluginManifestPath = getCachedPluginManifestPath(pluginManifestUrlString); - Path cacheDir = getCachedPluginsBaseDirectory(); - Files.createDirectories(cacheDir); - Files.writeString(cachedPluginManifestPath, manifestContent); + Path cachedPluginManifestPath = getCachedPluginManifestPath(pluginManifestUrlString); + Path cacheDir = getCachedPluginsBaseDirectory(); + Files.createDirectories(cacheDir); + Path tmp = Files.createTempFile(cacheDir, ".manifest-", ".tmp"); + try { + Files.writeString(tmp, manifestContent); + Files.move(tmp, cachedPluginManifestPath, + StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING); + } catch (IOException e) { + Files.deleteIfExists(tmp); + throw e; + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java` around lines 227 - 235, The savePluginManifestContentInCache method currently writes in-place and can leave truncated files on crash; change it to write to a sibling temporary file (e.g., cachedPluginManifestPath + ".tmp"), create the cacheDir with getCachedPluginsBaseDirectory(), write manifestContent to the temp file, then atomically replace the target using Files.move(tempPath, cachedPluginManifestPath, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING); catch AtomicMoveNotSupportedException and fall back to Files.move(tempPath, cachedPluginManifestPath, StandardCopyOption.REPLACE_EXISTING) to maintain correctness across filesystems and avoid torn writes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java`:
- Line 52: Change the nullable Boolean field pluginManifestCacheEnabled in
PluginUtils to a primitive boolean with a safe default (e.g., false) so
auto-unboxing cannot NPE; update the field declaration from Boolean to boolean
and ensure any Spring property binding uses a default value or `@Value` fallback,
and remove/adjust any explicit null checks around pluginManifestCacheEnabled
used in the if conditions in PluginUtils (the expressions referenced where
pluginManifestCacheEnabled is read should now rely on the primitive boolean).
- Around line 217-225: The method getPluginManifestContentFromCache logs "Cache
for plugin [{}] not found." on a cache miss and the caller (the method that
invokes getPluginManifestContentFromCache and later logs "Cache not found for
plugin [{}].") duplicates the same message; remove the duplicate by deleting or
suppressing the caller's log so only getPluginManifestContentFromCache emits the
cache-miss message. Search for the exact strings "Cache for plugin [{}] not
found." and "Cache not found for plugin [{}]." and remove the latter from the
caller (or comment it out) so only the callee
(getPluginManifestContentFromCache) logs the miss.
- Around line 55-58: PLUGIN_LOCKS grows unbounded because getLockFor uses the
full substituted pluginUrl as the key; change getLockFor to derive and use a
stable, meeting-independent cache key (e.g., compute an MD5 of a normalized URL
or the manifest file name by replacing/stripping %%MEETING_ID%% or other
volatile segments) and call PLUGIN_LOCKS.computeIfAbsent with that stableKey
instead of the raw pluginUrl; update any callers (e.g., code in
getRawPluginManifestContent and anywhere replaceAllPlaceholdersInManifestUrls is
used) to pass the original URL but let getLockFor compute the normalized key so
locks are reused across meetings and the map no longer grows unbounded.
- Line 49: The field cachedPluginsBaseDirectory in class PluginUtils is publicly
mutable; change its visibility to private to enforce encapsulation, rely on the
existing setter setCachedPluginsBaseDirectory to mutate it, and update any
places that reference PluginUtils.cachedPluginsBaseDirectory directly to call
the setter or a new getter on PluginUtils instead so Spring-wired configuration
and controlled access are preserved.
- Around line 270-272: The boolean check for isRawPluginManifestContentValid can
NPE because getPluginName(pluginManifestContent) may return null; update the
check to safely handle null by calling getPluginName once into a local variable
(e.g., String pluginName = getPluginName(pluginManifestContent)) and then use
pluginName != null && !pluginName.isEmpty() (or change getPluginName to return
"" instead of null) so isRawPluginManifestContentValid uses
isPluginManifestChecksumValid(pluginManifestContent, pluginManifestChecksum) &&
pluginName != null && !pluginName.isEmpty(); ensure you reference getPluginName
and isPluginManifestChecksumValid when applying the fix.
---
Nitpick comments:
In `@bbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java`:
- Around line 227-235: The savePluginManifestContentInCache method currently
writes in-place and can leave truncated files on crash; change it to write to a
sibling temporary file (e.g., cachedPluginManifestPath + ".tmp"), create the
cacheDir with getCachedPluginsBaseDirectory(), write manifestContent to the temp
file, then atomically replace the target using Files.move(tempPath,
cachedPluginManifestPath, StandardCopyOption.ATOMIC_MOVE,
StandardCopyOption.REPLACE_EXISTING); catch AtomicMoveNotSupportedException and
fall back to Files.move(tempPath, cachedPluginManifestPath,
StandardCopyOption.REPLACE_EXISTING) to maintain correctness across filesystems
and avoid torn writes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 3f424736-9ee4-448a-b50a-3d8f4777074e
📒 Files selected for processing (2)
bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.javabbb-common-web/src/main/java/org/bigbluebutton/api/util/PluginUtils.java
🚧 Files skipped from review as they are similar to previous changes (1)
- bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java
|
This pull request has conflicts ☹ |
…port and a path that is exactly /plugins or a descendant of it
paultrudel
left a comment
There was a problem hiding this comment.
Since the resolved URL with placeholders removed is used as the cache key, is it not the case that any plugin URL with a %%MEETING_ID%% placeholder will always result in a cache miss? Since the substituted meeting ID will be unique per meeting resulting in a unique plugin URL. Would it make sense to just skip caching URLs with meeting ID placeholders?
Agreed and applied. Thanks for the suggestion. |
|
✅ Automated tests have passed! |
c8a3272
into
bigbluebutton:v3.0.x-develop
|
Hello @gustavotrott I'd suggest renaming "cache" to "mirror" here. A cache is passive: it refreshes through access (miss → fetch → store), never on its own. This PR does the opposite: persistent local copy with a scheduled cron.daily wipe forcing re-download regardless of access. That's an on-demand mirror with periodic sync, not a cache. The name matters because Suggested rename:
Easier to fix now than after the flag ships. Since it's already merged, worth a follow-up PR for the rename. |
I understand the concern, but I do not think a cache is necessarily passive or access-triggered.
There are cache systems where refresh is proactive and schedule-driven. For example, IBM BigMemory Max / Ehcache has a "Scheduled Refresh Ahead" strategy, where refresh-ahead operations can run on a regular schedule using Quartz jobs and a cron expression: Their docs describe this as useful when all or a large portion of a cache's data must be updated regularly. Another example is Sybase/SAP Unwired Server's "Scheduled Cache Refreshes", which describes a schedule-driven cache refresh as a background task that runs at scheduled intervals during normal server operation: So I do not think the scheduled update makes this stop being a cache. It is still a local cached copy of the plugin manifests, used to avoid repeated remote fetches during meeting creation. The daily update is only the refresh strategy used to keep the cached manifests fresh. To me, Because of that, I still think |



What does this PR do?
pluginManifestCacheEnabled;luginManifestCacheRefreshIntervalMinutes=60Closes Issue(s)
Closes bigbluebutton/bigbluebutton-html-plugin-sdk#223
Motivation
This PR is meant to enhance speed of creating a meeting, if all the plugins are cached, there is no need to fetch their files and therefore no latency is added.
How to test
pluginManifestCacheEnabledis set to true inbigbluebutton.properties);/var/bigbluebutton/plugin-manifests-cache;