Fix warnings and handle deprecations (#5421)

* Fix warnings and handle deprecations
* Potential fix for pull request finding

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
Holger Friedrich
2026-03-26 22:42:56 +01:00
committed by GitHub
parent 5bc5a1c311
commit 5aadd40c97
9 changed files with 39 additions and 22 deletions
@@ -125,7 +125,7 @@ public class ThingStatusConditionHandler extends BaseConditionModuleHandler impl
if (thing == null) { if (thing == null) {
logger.error("Thing with UID {} not found in ThingRegistry for condition of rule {}.", thingUID, ruleUID); logger.error("Thing with UID {} not found in ThingRegistry for condition of rule {}.", thingUID, ruleUID);
} else } else {
switch (operator) { switch (operator) {
case "=": case "=":
return thing.getStatus().equals(status); return thing.getStatus().equals(status);
@@ -134,6 +134,7 @@ public class ThingStatusConditionHandler extends BaseConditionModuleHandler impl
default: default:
logger.error("Thing status condition operator {} is not known of rule {}", operator, ruleUID); logger.error("Thing status condition operator {} is not known of rule {}", operator, ruleUID);
} }
}
return false; return false;
} }
@@ -110,6 +110,10 @@ public class CertificateGenerator implements BundleActivator {
*/ */
private KeyStore ensureKeystore() throws KeyStoreException { private KeyStore ensureKeystore() throws KeyStoreException {
String keystorePath = System.getProperty(JETTY_KEYSTORE_PATH_PROPERTY); String keystorePath = System.getProperty(JETTY_KEYSTORE_PATH_PROPERTY);
if (keystorePath == null || keystorePath.isEmpty()) {
throw new KeyStoreException(
"Keystore path system property '" + JETTY_KEYSTORE_PATH_PROPERTY + "' is not set.");
}
keystoreFile = new File(keystorePath); keystoreFile = new File(keystorePath);
KeyStore keyStore = KeyStore.getInstance(KEYSTORE_JKS_TYPE); KeyStore keyStore = KeyStore.getInstance(KEYSTORE_JKS_TYPE);
if (!keystoreFile.exists()) { if (!keystoreFile.exists()) {
@@ -184,7 +188,7 @@ public class CertificateGenerator implements BundleActivator {
X500Name subjectDN = new X500Name(X500_NAME); X500Name subjectDN = new X500Name(X500_NAME);
byte[] publickeyb = publicKey.getEncoded(); byte[] publickeyb = publicKey.getEncoded();
ASN1Sequence sequence = (ASN1Sequence) ASN1Primitive.fromByteArray(publickeyb); ASN1Sequence sequence = (ASN1Sequence) ASN1Primitive.fromByteArray(publickeyb);
SubjectPublicKeyInfo subPubKeyInfo = new SubjectPublicKeyInfo(sequence); SubjectPublicKeyInfo subPubKeyInfo = SubjectPublicKeyInfo.getInstance(sequence);
X509v3CertificateBuilder v3CertGen = new X509v3CertificateBuilder(issuerDN, serialNumber, notBefore, X509v3CertificateBuilder v3CertGen = new X509v3CertificateBuilder(issuerDN, serialNumber, notBefore,
notAfter, subjectDN, subPubKeyInfo); notAfter, subjectDN, subPubKeyInfo);
@@ -27,7 +27,14 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.audio.*; import org.openhab.core.audio.AudioFormat;
import org.openhab.core.audio.AudioSink;
import org.openhab.core.audio.AudioStream;
import org.openhab.core.audio.FixedLengthAudioStream;
import org.openhab.core.audio.PipedAudioStream;
import org.openhab.core.audio.SizeableAudioStream;
import org.openhab.core.audio.UnsupportedAudioFormatException;
import org.openhab.core.audio.UnsupportedAudioStreamException;
import org.openhab.core.audio.utils.AudioWaveUtils; import org.openhab.core.audio.utils.AudioWaveUtils;
import org.openhab.core.library.types.PercentType; import org.openhab.core.library.types.PercentType;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -25,7 +25,11 @@ import java.util.concurrent.ScheduledExecutorService;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.audio.*; import org.openhab.core.audio.AudioException;
import org.openhab.core.audio.AudioFormat;
import org.openhab.core.audio.AudioSource;
import org.openhab.core.audio.AudioStream;
import org.openhab.core.audio.PipedAudioStream;
import org.openhab.core.common.ThreadPoolManager; import org.openhab.core.common.ThreadPoolManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -171,8 +171,9 @@ public class ChannelTransformation {
} catch (TransformationException e) { } catch (TransformationException e) {
if (e.getCause() instanceof ScriptException ex) { if (e.getCause() instanceof ScriptException ex) {
logger.error("Applying {} failed: {}", this, ex.getMessage()); logger.error("Applying {} failed: {}", this, ex.getMessage());
} else } else {
logger.debug("Applying {} failed: {}", this, e.getMessage()); logger.debug("Applying {} failed: {}", this, e.getMessage());
}
} }
} else { } else {
logger.warn("Failed to use {}, service not found", this); logger.warn("Failed to use {}, service not found", this);
@@ -59,8 +59,8 @@ class GsonTest {
assertNotNull(json, "JSON content should not be null"); assertNotNull(json, "JSON content should not be null");
assertFalse(json.isEmpty(), "JSON content should not be empty"); assertFalse(json.isEmpty(), "JSON content should not be empty");
// Deserialize into GsonTestClass_DTO // Deserialize into GsonTestClassDTO
GsonTestClass_DTO test = GSON.fromJson(json, GsonTestClass_DTO.class); GsonTestClassDTO test = GSON.fromJson(json, GsonTestClassDTO.class);
assertNotNull(test, "Deserialized object should not be null"); assertNotNull(test, "Deserialized object should not be null");
// Verify all fields are correctly deserialized // Verify all fields are correctly deserialized
@@ -77,8 +77,8 @@ class GsonTest {
assertNotNull(json, "JSON content should not be null"); assertNotNull(json, "JSON content should not be null");
assertFalse(json.isEmpty(), "JSON content should not be empty"); assertFalse(json.isEmpty(), "JSON content should not be empty");
// Deserialize into GsonTestClassAnnotated_DTO // Deserialize into GsonTestClassAnnotatedDTO
GsonTestClassAnnotated_DTO test = GSON.fromJson(json, GsonTestClassAnnotated_DTO.class); GsonTestClassAnnotatedDTO test = GSON.fromJson(json, GsonTestClassAnnotatedDTO.class);
assertNotNull(test, "Deserialized object should not be null"); assertNotNull(test, "Deserialized object should not be null");
// Verify all fields are correctly deserialized // Verify all fields are correctly deserialized
@@ -95,8 +95,8 @@ class GsonTest {
assertNotNull(json, "JSON content should not be null"); assertNotNull(json, "JSON content should not be null");
assertFalse(json.isEmpty(), "JSON content should not be empty"); assertFalse(json.isEmpty(), "JSON content should not be empty");
// Deserialize into GsonTestClassAnnotated2_DTO // Deserialize into GsonTestClassAnnotated2DTO
GsonTestClassAnnotated2_DTO test = GSON.fromJson(json, GsonTestClassAnnotated2_DTO.class); GsonTestClassAnnotated2DTO test = GSON.fromJson(json, GsonTestClassAnnotated2DTO.class);
assertNotNull(test, "Deserialized object should not be null"); assertNotNull(test, "Deserialized object should not be null");
// Verify all fields are correctly deserialized // Verify all fields are correctly deserialized
@@ -23,16 +23,16 @@ import com.google.gson.annotations.SerializedName;
* @author Holger Friedrich - Initial contribution * @author Holger Friedrich - Initial contribution
*/ */
@NonNullByDefault @NonNullByDefault
public class GsonTestClassAnnotated2_DTO { public class GsonTestClassAnnotated2DTO {
public @SerializedName("name") @Nullable String n; public @SerializedName("name") @Nullable String n;
public @Nullable @SerializedName("email") String e; public @Nullable @SerializedName("email") String e;
public int age; public int age;
public boolean active; public boolean active;
public GsonTestClassAnnotated2_DTO() { public GsonTestClassAnnotated2DTO() {
} }
public GsonTestClassAnnotated2_DTO(String name, int age, String email, boolean active) { public GsonTestClassAnnotated2DTO(String name, int age, String email, boolean active) {
this.n = name; this.n = name;
this.e = email; this.e = email;
this.age = age; this.age = age;
@@ -41,7 +41,7 @@ public class GsonTestClassAnnotated2_DTO {
@Override @Override
public String toString() { public String toString() {
return "GsonTestClassAnnotated2_DTO{" + "name='" + n + '\'' + ", age=" + age + ", email='" + e + '\'' return "GsonTestClassAnnotated2DTO{" + "name='" + n + '\'' + ", age=" + age + ", email='" + e + '\''
+ ", active=" + active + '}'; + ", active=" + active + '}';
} }
} }
@@ -22,17 +22,17 @@ import com.google.gson.annotations.SerializedName;
* @author Holger Friedrich - Initial contribution * @author Holger Friedrich - Initial contribution
*/ */
@NonNullByDefault @NonNullByDefault
public class GsonTestClassAnnotated_DTO { public class GsonTestClassAnnotatedDTO {
// adding annotations in different order is intended, please do not sort! // adding annotations in different order is intended, please do not sort!
public @SerializedName("name") @NonNullByDefault({}) String n = null; public @SerializedName("name") @NonNullByDefault({}) String n = null;
public @NonNullByDefault({}) @SerializedName("email") String e = null; public @NonNullByDefault({}) @SerializedName("email") String e = null;
public int age; public int age;
public boolean active; public boolean active;
public GsonTestClassAnnotated_DTO() { public GsonTestClassAnnotatedDTO() {
} }
public GsonTestClassAnnotated_DTO(String name, int age, String email, boolean active) { public GsonTestClassAnnotatedDTO(String name, int age, String email, boolean active) {
this.n = name; this.n = name;
this.e = email; this.e = email;
this.age = age; this.age = age;
@@ -41,7 +41,7 @@ public class GsonTestClassAnnotated_DTO {
@Override @Override
public String toString() { public String toString() {
return "GsonTestClassAnnotated_DTO{" + "name='" + n + '\'' + ", age=" + age + ", email='" + e + '\'' return "GsonTestClassAnnotatedDTO{" + "name='" + n + '\'' + ", age=" + age + ", email='" + e + '\''
+ ", active=" + active + '}'; + ", active=" + active + '}';
} }
} }
@@ -17,16 +17,16 @@ package org.openhab.core.gson;
* *
* @author Holger Friedrich - Initial contribution * @author Holger Friedrich - Initial contribution
*/ */
public class GsonTestClass_DTO { public class GsonTestClassDTO {
public String name; public String name;
public int age; public int age;
public String email; public String email;
public boolean active; public boolean active;
public GsonTestClass_DTO() { public GsonTestClassDTO() {
} }
public GsonTestClass_DTO(String name, int age, String email, boolean active) { public GsonTestClassDTO(String name, int age, String email, boolean active) {
this.name = name; this.name = name;
this.age = age; this.age = age;
this.email = email; this.email = email;