Skip to content

Commit ca03080

Browse files
author
Alexey Semenyuk
committed
8368030: Make package bundlers stateless
Reviewed-by: almatvee
1 parent 648582a commit ca03080

32 files changed

+2414
-1498
lines changed

src/jdk.jpackage/linux/classes/jdk/jpackage/internal/DesktopIntegration.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.awt.image.BufferedImage;
3232
import java.io.File;
3333
import java.io.IOException;
34+
import java.io.UncheckedIOException;
3435
import java.nio.file.Path;
3536
import java.util.ArrayList;
3637
import java.util.Arrays;
@@ -67,7 +68,7 @@ final class DesktopIntegration extends ShellCustomAction {
6768
private static final List<String> REPLACEMENT_STRING_IDS = List.of(
6869
COMMANDS_INSTALL, COMMANDS_UNINSTALL, SCRIPTS, COMMON_SCRIPTS);
6970

70-
private DesktopIntegration(BuildEnv env, LinuxPackage pkg, LinuxLauncher launcher) throws IOException {
71+
private DesktopIntegration(BuildEnv env, LinuxPackage pkg, LinuxLauncher launcher) {
7172

7273
associations = launcher.fileAssociations().stream().map(
7374
LinuxFileAssociation::create).toList();
@@ -88,10 +89,14 @@ private DesktopIntegration(BuildEnv env, LinuxPackage pkg, LinuxLauncher launche
8889
// This is additional launcher with explicit `no icon` configuration.
8990
withDesktopFile = false;
9091
} else {
91-
final Path nullPath = null;
92-
if (curIconResource.get().saveToFile(nullPath) != OverridableResource.Source.DefaultResource) {
93-
// This launcher has custom icon configured.
94-
withDesktopFile = true;
92+
try {
93+
if (curIconResource.get().saveToFile((Path)null) != OverridableResource.Source.DefaultResource) {
94+
// This launcher has custom icon configured.
95+
withDesktopFile = true;
96+
}
97+
} catch (IOException ex) {
98+
// Should never happen as `saveToFile((Path)null)` should not perform any actual I/O operations.
99+
throw new UncheckedIOException(ex);
95100
}
96101
}
97102

@@ -135,13 +140,13 @@ private DesktopIntegration(BuildEnv env, LinuxPackage pkg, LinuxLauncher launche
135140
return (LinuxLauncher)v;
136141
}).filter(l -> {
137142
return toRequest(l.shortcut()).orElse(true);
138-
}).map(toFunction(l -> {
143+
}).map(l -> {
139144
return new DesktopIntegration(env, pkg, l);
140-
})).toList();
145+
}).toList();
141146
}
142147
}
143148

144-
static ShellCustomAction create(BuildEnv env, Package pkg) throws IOException {
149+
static ShellCustomAction create(BuildEnv env, Package pkg) {
145150
if (pkg.isRuntimeInstaller()) {
146151
return ShellCustomAction.nop(REPLACEMENT_STRING_IDS);
147152
}

0 commit comments

Comments
 (0)