diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2024-03-14 21:48:25 +0000 |
---|---|---|
committer | adheli.tavares <adheli.tavares@est.tech> | 2024-03-15 08:39:39 +0000 |
commit | 12142469280ab15d3c38802e6be7d7676435c2b9 (patch) | |
tree | 7b2803fb67ecd28c3f2d2c099c5ca35a55fe0627 | |
parent | e51bea1cd5dff02cd00ab93fd4a7f5726fa9a2fb (diff) |
Make drools-pdp work with drools and java versions compatible
with current DRL rules files syntax.
Issue-ID: POLICY-4857
Change-Id: If4b385bdef865d07114b8ea0e69abb4589f3a97b
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
22 files changed, 35 insertions, 70 deletions
diff --git a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockManagerTest.java b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockManagerTest.java index 74a3c761..2e173cf0 100644 --- a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockManagerTest.java +++ b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockManagerTest.java @@ -48,7 +48,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.io.Serial; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; @@ -967,7 +966,6 @@ class DistributedLockManagerTest { protected DistributedLock makeLock(LockState state, String resourceId, String ownerKey, int holdSec, LockCallback callback) { return new DistributedLock(state, resourceId, ownerKey, holdSec, callback, feature) { - @Serial private static final long serialVersionUID = 1L; @Override @@ -1352,7 +1350,6 @@ class DistributedLockManagerTest { protected DistributedLock makeLock(LockState state, String resourceId, String ownerKey, int holdSec, LockCallback callback) { return new DistributedLock(state, resourceId, ownerKey, holdSec, callback, feature) { - @Serial private static final long serialVersionUID = 1L; private int ntimes = 0; @@ -1721,7 +1718,6 @@ class DistributedLockManagerTest { LockCallback callback) { return new DistributedLock(state, resourceId, ownerKey, holdSec, callback, feature) { - @Serial private static final long serialVersionUID = 1L; private boolean checked = false; diff --git a/feature-lifecycle/pom.xml b/feature-lifecycle/pom.xml index 5aea16be..757f23b4 100644 --- a/feature-lifecycle/pom.xml +++ b/feature-lifecycle/pom.xml @@ -3,7 +3,7 @@ ONAP ================================================================================ Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. - Modifications Copyright (C) 2023 Nordix Foundation. + Modifications Copyright (C) 2023-2024 Nordix Foundation. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ <build> <plugins> <plugin> + <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> @@ -111,7 +112,6 @@ <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> </dependency> - </dependencies> </project> diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java index e7656ae6..7237eb91 100644 --- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java +++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java @@ -283,7 +283,8 @@ public class LifecycleFsm implements Startable { policyTypesMap.values().stream() .filter(PolicyTypeDroolsController.class::isInstance) .map(PolicyTypeDroolsController.class::cast) - .filter(opController -> opController.getControllers().containsKey(controller.getName())).toList(); + .filter(opController -> opController.getControllers().containsKey(controller.getName())) + .collect(Collectors.toList()); for (PolicyTypeDroolsController opController : opControllers) { opController.remove(controller); diff --git a/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureException.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureException.java index 5d7b9f76..eafa0a7b 100644 --- a/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureException.java +++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureException.java @@ -21,13 +21,10 @@ package org.onap.policy.drools.pooling; -import java.io.Serial; - /** * Exception thrown by the pooling feature. */ public class PoolingFeatureException extends Exception { - @Serial private static final long serialVersionUID = 1L; public PoolingFeatureException() { diff --git a/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureRtException.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureRtException.java index 5d0a2755..46b71979 100644 --- a/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureRtException.java +++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureRtException.java @@ -21,13 +21,10 @@ package org.onap.policy.drools.pooling; -import java.io.Serial; - /** * A runtime exception thrown by the pooling feature. */ public class PoolingFeatureRtException extends RuntimeException { - @Serial private static final long serialVersionUID = 1L; public PoolingFeatureRtException() { diff --git a/policy-core/pom.xml b/policy-core/pom.xml index 95e13945..35e64a76 100644 --- a/policy-core/pom.xml +++ b/policy-core/pom.xml @@ -5,7 +5,7 @@ ================================================================================ Copyright (C) 2017-2021, 2023 AT&T Intellectual Property. All rights reserved. Modifications Copyright (C) 2019 Bell Canada. - Modifications Copyright (C) 2020,2022-2023 Nordix Foundation. + Modifications Copyright (C) 2020,2022-2024 Nordix Foundation. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ <dependency> <groupId>org.apache.ant</groupId> <artifactId>ant</artifactId> - <version>1.10.13</version> + <version>1.10.14</version> </dependency> <dependency> @@ -115,17 +115,14 @@ <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-xjc</artifactId> - <version>4.0.3</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-core</artifactId> - <version>4.0.3</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> - <version>4.0.3</version> </dependency> <dependency> <groupId>jakarta.activation</groupId> @@ -139,6 +136,10 @@ <groupId>jakarta.xml.bind</groupId> <artifactId>jakarta.xml.bind-api</artifactId> </dependency> + <dependency> + <groupId>org.glassfish.hk2.external</groupId> + <artifactId>javax.inject</artifactId> + </dependency> </dependencies> </project> diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysFailLock.java b/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysFailLock.java index df0ac151..edb7f475 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysFailLock.java +++ b/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysFailLock.java @@ -21,7 +21,6 @@ package org.onap.policy.drools.core.lock; -import java.io.Serial; import lombok.NoArgsConstructor; /** @@ -29,7 +28,6 @@ import lombok.NoArgsConstructor; */ @NoArgsConstructor public class AlwaysFailLock extends LockImpl { - @Serial private static final long serialVersionUID = 1L; /** diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysSuccessLock.java b/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysSuccessLock.java index ced6c4c9..b4364515 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysSuccessLock.java +++ b/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysSuccessLock.java @@ -21,14 +21,12 @@ package org.onap.policy.drools.core.lock; -import java.io.Serial; import lombok.NonNull; /** * Lock implementation whose operations always succeed. */ public class AlwaysSuccessLock extends LockImpl { - @Serial private static final long serialVersionUID = 1L; /** diff --git a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerPolicy.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerPolicy.java index b16af396..dfb75da6 100644 --- a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerPolicy.java +++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerPolicy.java @@ -21,7 +21,6 @@ package org.onap.policy.drools.domain.models.controller; -import java.io.Serial; import java.io.Serializable; import lombok.Data; import lombok.EqualsAndHashCode; @@ -36,8 +35,6 @@ import org.onap.policy.drools.domain.models.DroolsPolicy; @SuperBuilder @EqualsAndHashCode(callSuper = true) public class ControllerPolicy extends DroolsPolicy implements Serializable { - - @Serial private static final long serialVersionUID = -8171337852833516581L; private ControllerProperties properties; diff --git a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerProperties.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerProperties.java index b55e4344..31854a71 100644 --- a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerProperties.java +++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerProperties.java @@ -21,7 +21,6 @@ package org.onap.policy.drools.domain.models.controller; -import java.io.Serial; import java.io.Serializable; import java.util.List; import java.util.Map; @@ -36,7 +35,6 @@ import lombok.Data; @Data @Builder public class ControllerProperties implements Serializable { - @Serial private static final long serialVersionUID = 1259434187110418986L; private String controllerName; diff --git a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSinkTopic.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSinkTopic.java index 57c07f2d..af5c1cb0 100644 --- a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSinkTopic.java +++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSinkTopic.java @@ -21,7 +21,6 @@ package org.onap.policy.drools.domain.models.controller; -import java.io.Serial; import java.io.Serializable; import lombok.Data; import lombok.EqualsAndHashCode; @@ -36,7 +35,6 @@ import lombok.experimental.SuperBuilder; @SuperBuilder @EqualsAndHashCode(callSuper = true) public class ControllerSinkTopic extends ControllerTopic implements Serializable { - @Serial private static final long serialVersionUID = 8770353732981476267L; @Override diff --git a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSourceTopic.java b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSourceTopic.java index 3c7f1f03..63bdc243 100644 --- a/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSourceTopic.java +++ b/policy-domains/src/main/java/org/onap/policy/drools/domain/models/controller/ControllerSourceTopic.java @@ -21,7 +21,6 @@ package org.onap.policy.drools.domain.models.controller; -import java.io.Serial; import java.io.Serializable; import lombok.Data; import lombok.EqualsAndHashCode; @@ -36,7 +35,6 @@ import lombok.experimental.SuperBuilder; @SuperBuilder @EqualsAndHashCode(callSuper = true) public class ControllerSourceTopic extends ControllerTopic implements Serializable { - @Serial private static final long serialVersionUID = -1732598566914643612L; @Override diff --git a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyTest.java b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyTest.java index 99494d71..e2e628a7 100644 --- a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyTest.java +++ b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyTest.java @@ -30,7 +30,6 @@ import com.openpojo.validation.Validator; import com.openpojo.validation.ValidatorBuilder; import com.openpojo.validation.test.impl.GetterTester; import com.openpojo.validation.test.impl.SetterTester; -import java.io.Serial; import java.io.Serializable; import java.util.List; import lombok.Data; @@ -46,7 +45,6 @@ class DroolsPolicyTest { @NoArgsConstructor @EqualsAndHashCode(callSuper = true) public static class DerivedDomainPolicy extends DroolsPolicy implements Serializable { - @Serial private static final long serialVersionUID = -1027974819756498893L; } diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java index 76836ba2..1201c26e 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java +++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java @@ -165,30 +165,32 @@ public class PdpdConfiguration { } protected boolean declaredProperty(String name, Object value) { - return switch (name) { - case "requestID" -> { + switch (name) { + case "requestID": callSetRequestId(value); - yield true; - } - case "entity" -> { + return true; + case "entity": callSetEntity(value); - yield true; - } - case "controllers" -> { + return true; + case "controllers": callSetControllers(value); - yield true; - } - default -> false; - }; + return true; + default: + return false; + } } protected Object declaredPropertyOrNotFound(String name, Object notFoundValue) { - return switch (name) { - case "requestID" -> getRequestId(); - case "entity" -> getEntity(); - case "controllers" -> getControllers(); - default -> notFoundValue; - }; + switch (name) { + case "requestID": + return getRequestId(); + case "entity": + return getEntity(); + case "controllers": + return getControllers(); + default: + return notFoundValue; + } } /** diff --git a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java index ecc6c083..ec06882f 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java +++ b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java @@ -1722,11 +1722,12 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA @Path("engine/tools/loggers") public Response loggers() { final List<String> names = new ArrayList<>(); - if (!(LoggerFactory.getILoggerFactory() instanceof LoggerContext context)) { + if (!(LoggerFactory.getILoggerFactory() instanceof LoggerContext)) { logger.warn("The SLF4J logger factory is not configured for logback"); return Response.status(Status.INTERNAL_SERVER_ERROR).entity(names).build(); } + final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); for (final Logger lgr : context.getLoggerList()) { names.add(lgr.getName()); } @@ -1744,11 +1745,12 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA @Path("engine/tools/loggers/{logger}") @Produces(MediaType.TEXT_PLAIN) public Response loggerName1(@PathParam("logger") String loggerName) { - if (!(LoggerFactory.getILoggerFactory() instanceof LoggerContext context)) { + if (!(LoggerFactory.getILoggerFactory() instanceof LoggerContext)) { logger.warn("The SLF4J logger factory is not configured for logback"); return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } + final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); var lgr = context.getLogger(loggerName); if (lgr == null) { return Response.status(Status.NOT_FOUND).build(); diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/internal/FeatureLockImplTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/internal/FeatureLockImplTest.java index 23511abd..8a10c516 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/system/internal/FeatureLockImplTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/system/internal/FeatureLockImplTest.java @@ -40,7 +40,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.io.Serial; import java.util.concurrent.ScheduledExecutorService; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; @@ -189,7 +188,6 @@ class FeatureLockImplTest { PolicySession session = mock(PolicySession.class); MyLock lock = new MyLock(LockState.WAITING, RESOURCE, OWNER_KEY, HOLD_SEC, callback) { - @Serial private static final long serialVersionUID = 1L; @Override @@ -397,7 +395,6 @@ class FeatureLockImplTest { * Lock that inherits the normal getSession() method. */ public static class MyLockStdSession extends FeatureLockImpl { - @Serial private static final long serialVersionUID = 1L; protected int nupdates = 0; @@ -433,7 +430,6 @@ class FeatureLockImplTest { } public static class MyLock extends MyLockStdSession { - @Serial private static final long serialVersionUID = 1L; public MyLock() { @@ -451,7 +447,6 @@ class FeatureLockImplTest { } public static class MyLockNoFeature extends MyLock { - @Serial private static final long serialVersionUID = 1L; public MyLockNoFeature() { diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/internal/LockManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/internal/LockManagerTest.java index 74e1a9c1..47d0f275 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/system/internal/LockManagerTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/system/internal/LockManagerTest.java @@ -33,7 +33,6 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.io.Serial; import java.util.concurrent.ScheduledExecutorService; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -225,7 +224,6 @@ class LockManagerTest { } private class MyLock extends FeatureLockImpl { - @Serial private static final long serialVersionUID = 1L; public MyLock(LockState waiting, String resourceId, String ownerKey, int holdSec, LockCallback callback) { diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerTest.java index 3ee5583a..242492bb 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerTest.java @@ -44,7 +44,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.io.Serial; import java.util.ArrayList; import java.util.List; import java.util.Properties; @@ -310,7 +309,6 @@ class SimpleLockManagerTest { protected SimpleLock makeLock(LockState waiting, String resourceId, String ownerKey, int holdSec, LockCallback callback) { return new SimpleLock(waiting, resourceId, ownerKey, holdSec, callback, feature) { - @Serial private static final long serialVersionUID = 1L; @Override @@ -367,7 +365,6 @@ class SimpleLockManagerTest { madeLock = true; return new SimpleLock(waiting, resourceId, ownerKey, holdSec, callback, feature) { - @Serial private static final long serialVersionUID = 1L; @Override diff --git a/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Metadata.java b/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Metadata.java index e81bdd05..0707e411 100644 --- a/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Metadata.java +++ b/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Metadata.java @@ -22,7 +22,6 @@ package org.onap.policy.drools.models.domains.a; import com.google.gson.annotations.SerializedName; -import java.io.Serial; import java.io.Serializable; import lombok.Builder; import lombok.Data; @@ -30,7 +29,6 @@ import lombok.Data; @Data @Builder public class Metadata implements Serializable { - @Serial private static final long serialVersionUID = 476541531265304644L; @SerializedName("policy-id") diff --git a/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Nested.java b/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Nested.java index 1d46d59d..711e064e 100644 --- a/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Nested.java +++ b/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Nested.java @@ -22,7 +22,6 @@ package org.onap.policy.drools.models.domains.a; import com.google.gson.annotations.SerializedName; -import java.io.Serial; import java.io.Serializable; import lombok.Builder; import lombok.Data; @@ -30,7 +29,6 @@ import lombok.Data; @Data @Builder public class Nested implements Serializable { - @Serial private static final long serialVersionUID = -1203143214137354429L; @SerializedName("nested1") diff --git a/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Properties.java b/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Properties.java index e323e8ac..d403ad22 100644 --- a/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Properties.java +++ b/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Properties.java @@ -22,7 +22,6 @@ package org.onap.policy.drools.models.domains.a; import com.google.gson.annotations.SerializedName; -import java.io.Serial; import java.io.Serializable; import lombok.Builder; import lombok.Data; @@ -30,7 +29,6 @@ import lombok.Data; @Data @Builder public class Properties implements Serializable { - @Serial private static final long serialVersionUID = 8476625479607243095L; @SerializedName("nested") @@ -157,7 +157,7 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> - <release>${java.version}</release> + <release>11</release> </configuration> </plugin> <plugin> |