Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.

Commit 2d57c4f

Browse files
committed
Merge remote-tracking branch 'origin/copilot/sub-pr-113' into copilot/sub-pr-113
2 parents 68f1471 + ddd7d7a commit 2d57c4f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

surf-cloud-api/surf-cloud-api-common/src/main/kotlin/dev/slne/surf/cloud/api/common/player/ppdc/PersistentPlayerDataContainerView.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@ interface PersistentPlayerDataContainerView {
9797
*/
9898
const val MAX_NESTING_DEPTH = 512
9999

100+
/**
101+
* Ensures that the nesting depth does not exceed the maximum allowed limit.
102+
*
103+
* This function validates that the provided depth is within acceptable bounds,
104+
* preventing memory exhaustion from extremely deep nested structures.
105+
*
106+
* @param depth The current nesting depth to validate.
107+
* @param exceptionFactory A factory function that creates the exception to throw
108+
* when the depth exceeds the limit. Defaults to [IllegalStateException].
109+
* @throws Throwable When the depth exceeds [MAX_NESTING_DEPTH]. The specific exception
110+
* type is determined by the [exceptionFactory] parameter.
111+
*/
100112
inline fun ensureValidNestingDepth(
101113
depth: Int,
102114
exceptionFactory: (message: String) -> Throwable = ::IllegalStateException

0 commit comments

Comments
 (0)