Skip to content

Commit

Permalink
fix coredump issue when client not successfully connected but need di…
Browse files Browse the repository at this point in the history
…sconnect (#28)

* fix coredump issue when client not successfully connected but need disconnect

* use flag to indicate exception happened or not
  • Loading branch information
yma11 authored Jul 30, 2021
1 parent 816d602 commit cc49b68
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.List;

import org.apache.arrow.plasma.exceptions.DuplicateObjectException;
import org.apache.arrow.plasma.exceptions.PlasmaClientException;
import org.apache.arrow.plasma.exceptions.PlasmaOutOfMemoryException;

/**
Expand All @@ -35,13 +36,27 @@ public class PlasmaClient implements ObjectStoreLink {

private final long conn;

private boolean hasConnectException = false;

protected void finalize() {
PlasmaClientJNI.disconnect(this.conn);
if (!hasConnectException) {
PlasmaClientJNI.disconnect(this.conn);
}
}

// use plasma client to initialize the underlying jni system as well via config and config-overwrites
/**
* use plasma client to initialize the underlying jni system as well via config and config-overwrites.
* @param storeSocketName Socket path of Plasma server
* @param managerSocketName managerSocketName
* @param releaseDelay releaseDelay
*/
public PlasmaClient(String storeSocketName, String managerSocketName, int releaseDelay) {
this.conn = PlasmaClientJNI.connect(storeSocketName, managerSocketName, releaseDelay);
try {
this.conn = PlasmaClientJNI.connect(storeSocketName, managerSocketName, releaseDelay);
} catch (PlasmaClientException e) {
hasConnectException = true;
throw e;
}
}

// interface methods --------------------
Expand Down

0 comments on commit cc49b68

Please sign in to comment.