Sitelet https://github.com/NodeOps-app/createos-java-sdk/commit/e002230f120a47d16f84165353a0aa9e8691e88c
Skip to content

Commit e002230

Browse files
fix(examples): clean up networks and extend timeout
1 parent 080495d commit e002230

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
All notable changes will be documented here. This project follows Semantic
44
Versioning and the Keep a Changelog structure.
55

6+
## Unreleased
7+
8+
### Fixed
9+
10+
- Detach network members before deleting the network in the example.
11+
- Allow more time to create a sandbox from a custom template in the example.
12+
613
## 0.1.1 - 2026-09-17
714

815
### Fixed

‎examples/src/main/java/sh/createos/examples/customtemplate/CustomTemplate.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private CustomTemplate() {}
2727

2828
/** Runs the example. */
2929
public static void main(String[] arguments) throws InterruptedException {
30-
CreateOsClient client = CreateOsClient.builder().build();
30+
CreateOsClient client = CreateOsClient.builder().timeout(Duration.ofMinutes(5)).build();
3131
Template template =
3232
client
3333
.templates()

‎examples/src/main/java/sh/createos/examples/network/NetworkExample.java‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ public static void main(String[] arguments) {
1515
CreateOsClient client = CreateOsClient.builder().build();
1616
Network network = client.networks().create("java-sdk-" + Instant.now().getEpochSecond());
1717
Sandbox sandbox = null;
18+
boolean attached = false;
1819
try {
1920
sandbox =
2021
client.createSandbox(
2122
CreateSandboxRequest.builder("s-1vcpu-1gb").rootFileSystem("devbox:1").build());
2223
sandbox.attachNetwork(network.id());
24+
attached = true;
2325
Network connected = client.networks().get(network.id());
2426
String sandboxId = sandbox.id();
2527
Network.Member member =
@@ -31,10 +33,19 @@ public static void main(String[] arguments) {
3133
"verified member: sandbox=%s ip=%s status=%s%n",
3234
member.sandboxId(), member.ipAddress(), member.status());
3335
} finally {
34-
if (sandbox != null) {
35-
sandbox.destroy();
36+
try {
37+
if (sandbox != null && attached) {
38+
sandbox.detachNetwork(network.id());
39+
}
40+
} finally {
41+
try {
42+
if (sandbox != null) {
43+
sandbox.destroy();
44+
}
45+
} finally {
46+
client.networks().delete(network.id());
47+
}
3648
}
37-
client.networks().delete(network.id());
3849
}
3950
}
4051
}

0 commit comments

Comments
 (0)