Skip to content

Commit 0b1bbeb

Browse files
committed
Improve the "temp-extensions" workaround:
- Cleanup code
1 parent 2ab6dab commit 0b1bbeb

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQContainer.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,20 @@ private boolean removePrepackagedExtensions() {
146146
}
147147

148148
@Override
149-
public void copyFileToContainer(final @NotNull MountableFile mountableFile, @NotNull String containerPath) {
150-
if (!isStarted && removePrepackagedExtensions() && containerPath.startsWith("/opt/hivemq/extensions/")) {
151-
containerPath = "/opt/hivemq/temp-extensions/" + containerPath.substring("/opt/hivemq/extensions/".length());
152-
}
153-
super.copyFileToContainer(mountableFile, containerPath);
149+
public void copyFileToContainer(final @NotNull MountableFile mountableFile, final @NotNull String containerPath) {
150+
super.copyFileToContainer(mountableFile, mapContainerPathIfRequired(containerPath));
154151
}
155152

156153
@Override
157-
public void copyFileToContainer(final @NotNull Transferable transferable, @NotNull String containerPath) {
154+
public void copyFileToContainer(final @NotNull Transferable transferable, final @NotNull String containerPath) {
155+
super.copyFileToContainer(transferable, mapContainerPathIfRequired(containerPath));
156+
}
157+
158+
private @NotNull String mapContainerPathIfRequired(final @NotNull String containerPath) {
158159
if (!isStarted && removePrepackagedExtensions() && containerPath.startsWith("/opt/hivemq/extensions/")) {
159-
containerPath = "/opt/hivemq/temp-extensions/" + containerPath.substring("/opt/hivemq/extensions/".length());
160+
return "/opt/hivemq/temp-extensions/" + containerPath.substring("/opt/hivemq/extensions/".length());
160161
}
161-
super.copyFileToContainer(transferable, containerPath);
162+
return containerPath;
162163
}
163164

164165
protected void containerIsStarted(final @NotNull InspectContainerResponse containerInfo) {

0 commit comments

Comments
 (0)