You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/05/16 12:10:35 UTC
incubator-tinkerpop git commit: TINKERPOP-1302 Added shutdown hook to
close open remotes.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/tp31 1275437f2 -> 0a34d2dde
TINKERPOP-1302 Added shutdown hook to close open remotes.
Console mediator close doesn't need a Future. Not sure what was going on here (maybe incomplete??), but there was no need to return a CompletableFuture from Mediator.close() as the close was synchronous. It's also probably not a good idea to leave remotes open as they can leak remote resources. Change to a straight synchronous approach. CTR
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/0a34d2dd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/0a34d2dd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/0a34d2dd
Branch: refs/heads/tp31
Commit: 0a34d2ddee45159ea258fbf20a258b4e5a82b0bd
Parents: 1275437
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon May 16 07:30:53 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon May 16 08:10:00 2016 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../apache/tinkerpop/gremlin/console/Console.groovy | 14 ++++++--------
.../apache/tinkerpop/gremlin/console/Mediator.groovy | 4 +---
3 files changed, 8 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0a34d2dd/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 7fb58fa..1e33187 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -29,6 +29,7 @@ TinkerPop 3.1.3 (NOT OFFICIALLY RELEASED YET)
* Fixed a bug in `BulkSet.equals()` which made itself apparent when using `store()` and `aggregate()` with labeled `cap()`.
* Ensured that all asserts of vertex and edge counts were being applied properly in the test suite.
* Fixed bug in `gremlin-driver` where certain channel-level errors would not allow the driver to reconnect.
+* Use of `Ctrl-C` in Gremlin Console now triggers closing of open remotes.
* Bumped SLF4J to 1.7.21 as previous versions suffered from a memory leak.
* Fixed a bug in `Neo4jGraphStepStrategy` where it wasn't defined properly as a `ProviderOptimizationStrategy`.
* Renamed `AndTest.get_g_V_andXhasXage_gt_27X__outE_count_gt_2X_name` to `get_g_V_andXhasXage_gt_27X__outE_count_gte_2X_name` to match the traversal being tested.
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0a34d2dd/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
index a13e785..0daf650 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
@@ -34,7 +34,6 @@ import org.codehaus.groovy.tools.shell.util.Preferences
import org.fusesource.jansi.Ansi
import org.fusesource.jansi.AnsiConsole
-import java.util.concurrent.TimeUnit
import java.util.prefs.PreferenceChangeEvent
import java.util.prefs.PreferenceChangeListener
@@ -87,6 +86,10 @@ class Console {
})
final Mediator mediator = new Mediator(this)
+
+ // make sure that remotes are closed if console takes a ctrl-c
+ addShutdownHook { mediator.close() }
+
groovy = new GremlinGroovysh(mediator)
def commandsToRemove = groovy.getRegistry().commands().findAll{it instanceof SetCommand}
@@ -150,13 +153,8 @@ class Console {
} catch (Throwable t) {
t.printStackTrace()
} finally {
- try {
- mediator.close().get(3, TimeUnit.SECONDS)
- } catch (Exception ignored) {
- // ok if this times out - just trying to be polite on shutdown
- } finally {
- System.exit(0)
- }
+ // shutdown hook defined above will kill any open remotes
+ System.exit(0)
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0a34d2dd/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy
index a1235fa..047e3d7 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy
@@ -93,7 +93,7 @@ class Mediator {
return file.exists() ? file.readLines() : []
}
- def CompletableFuture<Void> close() {
+ def void close() {
remotes.each { remote ->
try {
remote.close()
@@ -101,8 +101,6 @@ class Mediator {
}
}
-
- return CompletableFuture.completedFuture(null)
}
}