Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ab05bc1

Browse filesBrowse files
committed
leader election autoclosable example
1 parent 351f180 commit ab05bc1
Copy full SHA for ab05bc1

File tree

Expand file treeCollapse file tree

1 file changed

+9
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-9
lines changed
Open diff view settings
Collapse file

‎examples/src/main/java/io/kubernetes/client/examples/LeaderElectionExample.java‎

Copy file name to clipboardExpand all lines: examples/src/main/java/io/kubernetes/client/examples/LeaderElectionExample.java
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ public static void main(String[] args) throws Exception {
4343
LeaderElectionConfig leaderElectionConfig =
4444
new LeaderElectionConfig(
4545
lock, Duration.ofMillis(10000), Duration.ofMillis(8000), Duration.ofMillis(2000));
46-
LeaderElector leaderElector = new LeaderElector(leaderElectionConfig);
47-
48-
leaderElector.run(
49-
() -> {
50-
System.out.println("Do something when getting leadership.");
51-
},
52-
() -> {
53-
System.out.println("Do something when losing leadership.");
54-
});
46+
try (LeaderElector leaderElector = new LeaderElector(leaderElectionConfig)) {
47+
leaderElector.run(
48+
() -> {
49+
System.out.println("Do something when getting leadership.");
50+
},
51+
() -> {
52+
System.out.println("Do something when losing leadership.");
53+
});
54+
}
5555
}
5656
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.