Skip to content

Commit

Permalink
Ryan/Devin Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nbauernfeind committed Jan 9, 2024
1 parent e9fc414 commit b5946e1
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions server/src/main/java/io/deephaven/server/session/SessionState.java
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ public final static class ExportObject<T> extends LivenessArtifact {

/** used to detect when this object is ready for export (is visible for atomic int field updater) */
private volatile int dependentCount = -1;
/** used to detect a parent that was already released prior to having dependencies set */
/** our first parent that was already released prior to having dependencies set if one exists */
private ExportObject<?> alreadyDeadParent;

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -651,9 +651,23 @@ private synchronized void setDependencies(final List<ExportObject<?>> parents) {

this.parents = parents;
dependentCount = parents.size();
alreadyDeadParent = parents.stream()
.filter(p -> p != null && !tryManage(p))
.findFirst().orElse(null);
for (final ExportObject<?> parent : parents) {
if (parent != null && !tryManage(parent)) {
alreadyDeadParent = parent;
break;
}
}

if (alreadyDeadParent != null) {
// no point in holding references to other parents any longer; we've already failed
for (final ExportObject<?> parent : parents) {
if (parent == alreadyDeadParent) {
break;
} else if (parent != null) {
unmanage(parent);
}
}
}

if (log.isDebugEnabled()) {
final Exception e = new RuntimeException();
Expand Down Expand Up @@ -692,6 +706,7 @@ private synchronized void setWork(
// we defer this type of failure until setWork for consistency in error handling
if (alreadyDeadParent != null) {
onDependencyFailure(alreadyDeadParent);
alreadyDeadParent = null;
}

if (isExportStateTerminal(state)) {
Expand Down

0 comments on commit b5946e1

Please sign in to comment.