From c67897425198dfcc5e98016c32f9be4f41456fb8 Mon Sep 17 00:00:00 2001
From: Pavel Golikov
Date: Tue, 6 Oct 2020 14:39:26 +0300
Subject: [PATCH] [GH-12] Fix exception caused by offline cause localization
Use properties file to localize OfflineCause's description.
---
.../proxmox/VirtualMachineSlaveComputer.java | 15 +++------------
.../jenkinsci/plugins/proxmox/Messages.properties | 1 +
2 files changed, 4 insertions(+), 12 deletions(-)
create mode 100644 src/main/resources/org/jenkinsci/plugins/proxmox/Messages.properties
diff --git a/src/main/java/org/jenkinsci/plugins/proxmox/VirtualMachineSlaveComputer.java b/src/main/java/org/jenkinsci/plugins/proxmox/VirtualMachineSlaveComputer.java
index d9568f5..60ddc3e 100644
--- a/src/main/java/org/jenkinsci/plugins/proxmox/VirtualMachineSlaveComputer.java
+++ b/src/main/java/org/jenkinsci/plugins/proxmox/VirtualMachineSlaveComputer.java
@@ -5,10 +5,6 @@
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.jvnet.localizer.Localizable;
-import org.jvnet.localizer.ResourceBundleHolder;
-
-import hudson.Messages;
import hudson.model.Executor;
import hudson.model.Node;
import hudson.model.Queue;
@@ -18,11 +14,6 @@
public class VirtualMachineSlaveComputer extends SlaveComputer {
- /**
- * The resource bundle reference
- *
- */
- private final static ResourceBundleHolder holder = ResourceBundleHolder.get(Messages.class);
private AtomicBoolean isRevertingSnapshot = new AtomicBoolean(false);
public VirtualMachineSlaveComputer(Slave slave) {
@@ -34,8 +25,8 @@ public void tryReconnect() {
if(isRevertingSnapshot.get()) {
getListener().getLogger().println("INFO: trying to reconnect while snapshot revert - ignoring");
return;
- }
-
+ }
+
super.tryReconnect();
}
@@ -53,7 +44,7 @@ public void taskAccepted(Executor executor, Queue.Task task) {
try {
isRevertingSnapshot.set(true);
- final Future> disconnectFuture = disconnect(OfflineCause.create(new Localizable(holder, "Disconnect before snapshot revert")));
+ final Future> disconnectFuture = disconnect(OfflineCause.create(Messages._VirtualMachineSlaveComputer_disconnectBeforeSnapshotRevert()));
disconnectFuture.get();
getListener().getLogger().println("INFO: slave disconnected");
diff --git a/src/main/resources/org/jenkinsci/plugins/proxmox/Messages.properties b/src/main/resources/org/jenkinsci/plugins/proxmox/Messages.properties
new file mode 100644
index 0000000..bd44f06
--- /dev/null
+++ b/src/main/resources/org/jenkinsci/plugins/proxmox/Messages.properties
@@ -0,0 +1 @@
+VirtualMachineSlaveComputer.disconnectBeforeSnapshotRevert=Disconnect before snapshot revert
\ No newline at end of file