 While this may indicate a programming error (each object holding a resource must be disposed "exactly" once), it is simpler, more robust, and thus usually preferable for codice_2 to be idempotent (meaning "calling multiple times is the same as calling once").This is easily implemented by using the same boolean codice_32 field and checking it in a guard clause at the start of codice_2, in that case returning immediately, rather than raising an exception.Java distinguishes disposable types (those that implement AutoCloseable) from disposable types where dispose is idempotent (the subtype Closeable).