org.opensearch.migrations.replay.util.RefSafeHolder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of trafficReplayer Show documentation
Show all versions of trafficReplayer Show documentation
Everything opensearch migrations
The newest version!
package org.opensearch.migrations.replay.util;
import javax.annotation.Nullable;
import com.google.errorprone.annotations.MustBeClosed;
import io.netty.util.ReferenceCountUtil;
public class RefSafeHolder implements AutoCloseable {
private final T resource;
private RefSafeHolder(@Nullable T resource) {
this.resource = resource;
}
@MustBeClosed
public static RefSafeHolder create(@Nullable T resource) {
return new RefSafeHolder<>(resource);
}
public @Nullable T get() {
return resource;
}
@Override
public void close() {
ReferenceCountUtil.release(resource);
}
@Override
public String toString() {
return "RefSafeHolder{" + resource + "}";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy