Skip to content

Commit cc49b68

Browse files
authored
fix coredump issue when client not successfully connected but need disconnect (#28)
* fix coredump issue when client not successfully connected but need disconnect * use flag to indicate exception happened or not
1 parent 816d602 commit cc49b68

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

java/plasma/src/main/java/org/apache/arrow/plasma/PlasmaClient.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.List;
2424

2525
import org.apache.arrow.plasma.exceptions.DuplicateObjectException;
26+
import org.apache.arrow.plasma.exceptions.PlasmaClientException;
2627
import org.apache.arrow.plasma.exceptions.PlasmaOutOfMemoryException;
2728

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

3637
private final long conn;
3738

39+
private boolean hasConnectException = false;
40+
3841
protected void finalize() {
39-
PlasmaClientJNI.disconnect(this.conn);
42+
if (!hasConnectException) {
43+
PlasmaClientJNI.disconnect(this.conn);
44+
}
4045
}
4146

42-
// use plasma client to initialize the underlying jni system as well via config and config-overwrites
47+
/**
48+
* use plasma client to initialize the underlying jni system as well via config and config-overwrites.
49+
* @param storeSocketName Socket path of Plasma server
50+
* @param managerSocketName managerSocketName
51+
* @param releaseDelay releaseDelay
52+
*/
4353
public PlasmaClient(String storeSocketName, String managerSocketName, int releaseDelay) {
44-
this.conn = PlasmaClientJNI.connect(storeSocketName, managerSocketName, releaseDelay);
54+
try {
55+
this.conn = PlasmaClientJNI.connect(storeSocketName, managerSocketName, releaseDelay);
56+
} catch (PlasmaClientException e) {
57+
hasConnectException = true;
58+
throw e;
59+
}
4560
}
4661

4762
// interface methods --------------------

0 commit comments

Comments
 (0)