Skip to content

Commit 04b75f4

Browse files
authored
chore: fix bugs catalogued in CODEBASE_MAP and clean up debug output (#30)
1 parent 0e04a91 commit 04b75f4

8 files changed

Lines changed: 18 additions & 32 deletions

File tree

docs/CODEBASE_MAP.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,6 @@ Server (listens on spawn:// URI)
237237
ApplicationSubscriber receives ◄─── EmbeddedServer.createProducer().publish(item)
238238
```
239239

240-
**Known bugs in `spawn-jdk`:**
241-
- `PatchModule.detect()` has a split-on-`=` bug for `--patch-module=module=path` args (no limit — third segment dropped).
242-
- `AbstractHeapSize`: memory unit suffix derived from first letter of enum name — adding a misnamed `MemorySize` enum would produce wrong JVM flag silently.
243-
244240
---
245241

246242
### `spawn-local-platform`
@@ -322,16 +318,13 @@ Server (listens on spawn:// URI)
322318
| `ImageName` | (image reference) | Handles tags, SHA256 refs, registry prefixing |
323319
| `ExposedPort` | `ExposedPorts` | Metadata only; use `PublishPort` for host mapping |
324320
| `PublishPort` | `HostConfig.PortBindings` | |
325-
| `Bind` | `HostConfig.Binds` | **Bug:** `requireNonNull` checks wrong param name |
321+
| `Bind` | `HostConfig.Binds` | |
326322
| `Command` | `Cmd` | Sets container CMD array |
327323
| `ContainerName` | `?name=` query param | 409 if duplicate |
328324
| `NetworkName` | `HostConfig.NetworkMode` | |
329325
| `PublishAllPorts` | `HostConfig.PublishAllPorts` | `@Default ENABLED` |
330326
| `KillSignal` | `signal` query param | Enum: `SIGKILL` (`@Default`), `SIGTERM`, `SIGQUIT`, `SIGHUP` |
331327

332-
**Known bugs in `spawn-docker`:**
333-
- `Bind`: `requireNonNull` for `internalPath` references `externalPath` param name (copy-paste; runtime behavior correct)
334-
335328
---
336329

337330
### `spawn-docker-jdk`
@@ -363,11 +356,6 @@ Server (listens on spawn:// URI)
363356
| `model/DockerImage.java` | `Image` impl; `start()` creates then starts container; auto-removes on start failure |
364357
| `model/AbstractJsonBasedResult.java` | DI-injected `Session` + `JsonValue` (base-json); `at(keys)` / `text(keys)` / `intAt` / `boolAt` navigation helpers |
365358

366-
**Known bugs:**
367-
- `GetSystemEvents` and `DockerContainer` have debug `System.out.println` calls in production code
368-
- `CopyFiles` constructor validation inverts the check (throws when file has content instead of when it's empty)
369-
- `NetworkInformation.driver()` reads lowercase `"driver"` but Docker API returns `"Driver"` → always returns empty string
370-
- `ContainerInformation.links()`: splits on `:``ArrayIndexOutOfBoundsException` if link string has no colon
371359

372360
## Conventions
373361

spawn-docker-jdk/src/main/java/build/spawn/docker/jdk/command/GetSystemEvents.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import build.base.flow.Publicist;
2424
import build.base.flow.Subscriber;
25-
import build.base.json.JsonFormat;
2625
import build.base.json.JsonValue;
2726
import build.base.naming.UniqueNameGenerator;
2827
import build.spawn.docker.Event;
@@ -70,8 +69,6 @@ public void onNext(final JsonValue item) {
7069
final var context = createContext();
7170
context.bind(JsonValue.class).to(item);
7271

73-
System.out.println("Raw Event: [" + name + "] " + item.toJsonString(JsonFormat.PRETTY));
74-
7572
// publish "Action" events as ActionEvents
7673
if (item.asObject().has("Action")) {
7774
final var event = context.create(ActionEvent.class);

spawn-docker-jdk/src/main/java/build/spawn/docker/jdk/model/ContainerInformation.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,10 @@ public Stream<Link> links() {
118118
final List<Link> linkList = new ArrayList<>();
119119
for (final JsonValue entry : linksArray.values()) {
120120
final String text = entry instanceof JsonString s ? s.value() : entry.toJsonString();
121-
final String[] split = text.split(":");
122-
linkList.add(Link.of(split[0], split[1]));
121+
final String[] split = text.split(":", 2);
122+
if (split.length == 2) {
123+
linkList.add(Link.of(split[0], split[1]));
124+
}
123125
}
124126

125127
return linkList.stream();

spawn-docker-jdk/src/main/java/build/spawn/docker/jdk/model/DockerContainer.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ private void onPostInject() {
132132
// obtain the identity for the Container from the JsonValue
133133
this.id = jsonValue().getString("Id");
134134

135-
System.out.println("Created Container: " + this.id.substring(this.id.length() - 8));
136-
137135
// establish a CompletingSubscriber for the Container
138136
this.completingSubscriber = new CompletingSubscriber<>();
139137

@@ -147,10 +145,7 @@ private void onPostInject() {
147145
// establish the CompletableFuture to identify when the Container has started
148146
this.onStart = this.completingSubscriber.when(
149147
event -> "start".equals(event.action()),
150-
__ -> {
151-
System.out.println("Started Container: " + this.id.substring(this.id.length() - 8));
152-
return this;
153-
});
148+
__ -> this);
154149

155150
// establish the CompletableFuture to identify when the Container has terminated (died)
156151
this.onExit = this.completingSubscriber.when(event -> {
@@ -170,10 +165,7 @@ private void onPostInject() {
170165

171166
return false;
172167
},
173-
_ -> {
174-
System.out.println("Exited Container: " + this.id.substring(this.id.length() - 8));
175-
return this;
176-
});
168+
_ -> this);
177169

178170
this.exitValue = null;
179171
}

spawn-docker-jdk/src/main/java/build/spawn/docker/jdk/model/NetworkInformation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class NetworkInformation
3434

3535
@Override
3636
public String driver() {
37-
return text("driver");
37+
return text("Driver");
3838
}
3939

4040
@Override

spawn-jdk/src/main/java/build/spawn/jdk/option/AbstractHeapSize.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,14 @@ else if (memorySize == null) {
7777

7878
@Override
7979
public Stream<String> resolve(final Platform platform, final ConfigurationBuilder options) {
80-
return Stream.of(getOption() + this.units + this.memorySize.name().toLowerCase().substring(0, 1));
80+
final String suffix = switch (this.memorySize) {
81+
case B -> "";
82+
case KiB, KB -> "k";
83+
case MiB, MB -> "m";
84+
case GiB, GB -> "g";
85+
default -> throw new IllegalArgumentException("Unsupported memory size for heap: " + this.memorySize);
86+
};
87+
return Stream.of(getOption() + this.units + suffix);
8188
}
8289

8390
@Override

spawn-jdk/src/main/java/build/spawn/jdk/option/PatchModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public static Stream<PatchModule> detect() {
155155
.stream()
156156
.filter(argument -> argument.startsWith("--patch-module="))
157157
.map(argument -> argument.substring("--patch-module=".length()))
158-
.map(argument -> argument.split("="))
158+
.map(argument -> argument.split("=", 2))
159159
.map(array -> PatchModule.of(array[0], array[1]));
160160
}
161161
}

spawn-local-jdk/src/main/java/build/spawn/platform/local/jdk/LocalJDKLauncher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public LocalProcess createProcess(final LocalMachine machine,
186186
// --- launch the Java Application ---
187187
this.diagnostics.addRow("Application Launch Command", String.join(" ", processBuilder.command()));
188188

189-
LOGGER.info("\n" + "build.spawn: Launching JDK-based Application...\n"
189+
LOGGER.debug("\n" + "build.spawn: Launching JDK-based Application...\n"
190190
+ "--------------------------------------------------------------\n" + "{0}"
191191
+ "--------------------------------------------------------------", this.diagnostics);
192192

0 commit comments

Comments
 (0)