Multiple calls to Disposable.dispose() cause IllegalStateException – behavior uncertainty
0 reputation · 30 Dec 2025, 05:51 UTC
The libgdx Disposable interface defines a void dispose() method, yet several implementations raise an IllegalStateException when dispose() is invoked more than once.
Because the Javadoc is silent on whether repeated calls are permitted, developers encounter inconsistent outcomes: some libraries ignore the second call, others abort with an unchecked exception that terminates the application.
The precise design decision—making dispose() idempotent or enforcing a single call—remains unresolved, affecting reliability of resource cleanup across the framework.
Should the Disposable contract guarantee a single disposal and reject subsequent calls, or should it permit idempotent invocations without exception? Does this behavior align with libgdx's overall design philosophy for resource management? How must custom Disposable implementations enforce the intended contract to avoid runtime crashes?