Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close the inner context of a RegionedContextHolder if it was set #3155

Merged
merged 5 commits into from
Dec 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
package io.deephaven.engine.table.impl.sources.regioned;

import io.deephaven.engine.table.ChunkSource;
import io.deephaven.engine.table.Context;
import io.deephaven.engine.table.SharedContext;
import org.jetbrains.annotations.Nullable;

public class RegionContextHolder implements ChunkSource.FillContext {
private final int chunkCapacity;
private final SharedContext sharedContext;
private Object innerContext;
private Context innerContext;

public RegionContextHolder(final int chunkCapacity, @Nullable final SharedContext sharedContext) {

Expand All @@ -28,7 +29,7 @@ public boolean supportsUnboundedFill() {
*
* @param contextObject The context object
*/
public void setInnerContext(@Nullable final Object contextObject) {
public void setInnerContext(@Nullable final Context contextObject) {
this.innerContext = contextObject;
}

Expand All @@ -51,13 +52,21 @@ public SharedContext getSharedContext() {
}

/**
* Get the inner context value set by {@link #setInnerContext(Object)} and cast it to the templated type.
* Get the inner context value set by {@link #setInnerContext(Context)} and cast it to the templated type.
*
* @return The inner context value.
* @param <T> The desired result type
*/
public <T> T getInnerContext() {
public <T extends Context> T getInnerContext() {
// noinspection unchecked
return (T) innerContext;
}

@Override
public void close() {
if (innerContext != null) {
innerContext.close();
rcaudy marked this conversation as resolved.
Show resolved Hide resolved
innerContext = null;
}
}
}