You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/08/17 18:25:18 UTC
[camel-k-runtime] branch master updated: PMD (#424)
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git
The following commit(s) were added to refs/heads/master by this push:
new f82ef43 PMD (#424)
f82ef43 is described below
commit f82ef43dd2bc2ad4a6d60155f8e1ef62b30267a8
Author: Luca Burgazzoli <lb...@users.noreply.github.com>
AuthorDate: Mon Aug 17 20:23:48 2020 +0200
PMD (#424)
* code quality: add PMD profile (not enabled by default)
* code quality: fix PMD findings
---
.../dsl/{Components.java => Components.groovy} | 30 +-
.../camel/k/loader/js/JavaScriptSourceLoader.java | 5 +-
.../apache/camel/k/loader/js/dsl/Components.java | 2 +-
.../apache/camel/k/loader/xml/XmlSourceLoader.java | 4 +-
.../k/loader/yaml/spi/StepParserException.java | 4 +
camel-k-main/camel-k-runtime-main/pom.xml | 5 +
.../apache/camel/k/main/ApplicationRuntime.java | 1 +
.../java/org/apache/camel/k/main/RuntimeTest.java | 3 +-
.../k/quarkus/knative/deployment/Application.java | 3 +-
.../k/quarkus/deployment/DeploymentProcessor.java | 2 -
.../k/quarkus/ApplicationListenerAdapter.java | 15 +-
.../ApplicationRuntimeConfigSourceProvider.java | 4 -
camel-k-runtime-bom/pom.xml | 5 +
.../org/apache/camel/k/CompositeClassloader.java | 5 +-
.../src/main/java/org/apache/camel/k/Sources.java | 20 +-
.../apache/camel/k/listener/RoutesConfigurer.java | 2 +-
.../k/support/KubernetesPropertiesFunction.java | 3 +-
.../camel/k/cron/CronSourceLoaderInterceptor.java | 3 +-
.../http/PlatformHttpServiceContextCustomizer.java | 3 -
camel-k-runtime-knative/pom.xml | 5 +
.../knative/KnativeSourceLoaderInterceptor.java | 1 +
.../knative/KnativeSourceRoutesLoaderTest.java | 8 +-
.../component/knative/spi/KnativeEnvironment.java | 83 +--
camel-knative/camel-knative-http/pom.xml | 5 +
.../knative/http/KnativeHttpProducer.java | 2 +-
.../component/knative/http/KnativeHttpSupport.java | 6 +-
.../knative/http/KnativeHttpTransport.java | 4 +-
.../component/knative/http/KnativeHttpTest.java | 12 +-
camel-knative/{ => camel-knative-test}/pom.xml | 17 +-
.../knative/test/KnativeEnvironmentSupport.java | 105 +++
camel-knative/camel-knative/pom.xml | 5 +
.../camel/component/knative/KnativeComponent.java | 8 +-
.../component/knative/KnativeConfiguration.java | 3 -
.../camel/component/knative/KnativeEndpoint.java | 7 +-
.../component/knative/ce/CloudEventProcessors.java | 7 +-
.../component/knative/KnativeComponentTest.java | 5 +-
camel-knative/pom.xml | 1 +
pom.xml | 119 +++-
.../camel/k/tooling/maven/GenerateCatalogMojo.java | 76 +--
.../camel/k/tooling/maven/GenerateRestXML.java | 9 +-
.../maven/GenerateYamlLoaderSupportClasses.java | 58 +-
.../maven/GenerateYamlParserSupportClasses.java | 2 +-
.../camel/k/tooling/maven/GenerateYamlSchema.java | 67 +-
.../maven/model/CatalogComponentDefinition.java | 2 +-
.../maven/model/CatalogDataFormatDefinition.java | 2 +-
.../maven/model/CatalogLanguageDefinition.java | 2 +-
.../maven/processors/CatalogProcessor3x.java | 6 +-
.../k/tooling/maven/support/MavenSupport.java | 60 ++
tooling/pmd-ruleset.xml | 711 +++++++++++++++++++++
49 files changed, 1172 insertions(+), 345 deletions(-)
diff --git a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/Components.java b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/Components.groovy
similarity index 62%
rename from camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/Components.java
rename to camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/Components.groovy
index 90c73cf..7d409c5 100644
--- a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/Components.java
+++ b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/Components.groovy
@@ -14,33 +14,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.k.loader.groovy.dsl;
+package org.apache.camel.k.loader.groovy.dsl
-import org.apache.camel.CamelContext;
-import org.apache.camel.Component;
+import org.apache.camel.CamelContext
+import org.apache.camel.Component
-public class Components {
- private CamelContext context;
+class Components {
+ private final CamelContext context
- public Components(CamelContext context) {
- this.context = context;
+ Components(CamelContext context) {
+ this.context = context
}
- public Component get(String scheme) {
- return context.getComponent(scheme, true);
+ Component get(String scheme) {
+ return context.getComponent(scheme, true)
}
- public Component put(String scheme, Component instance) {
- context.addComponent(scheme, instance);
+ Component put(String scheme, Component instance) {
+ context.addComponent(scheme, instance)
return instance;
}
- public Component make(String scheme, String type) {
- final Class<?> clazz = context.getClassResolver().resolveClass(type);
- final Component instance = (Component)context.getInjector().newInstance(clazz);
+ Component make(String scheme, String type) {
+ final Class<?> clazz = context.getClassResolver().resolveClass(type)
+ final Component instance = (Component)context.getInjector().newInstance(clazz)
- context.addComponent(scheme, instance);
+ context.addComponent(scheme, instance)
return instance;
}
diff --git a/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/JavaScriptSourceLoader.java b/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/JavaScriptSourceLoader.java
index d8de8e4..790a69c 100644
--- a/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/JavaScriptSourceLoader.java
+++ b/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/JavaScriptSourceLoader.java
@@ -61,8 +61,9 @@ public class JavaScriptSourceLoader implements SourceLoader {
//
// Expose IntegrationConfiguration methods to global scope.
//
- context.eval(LANGUAGE_ID, ""
- + "Object.setPrototypeOf(globalThis, new Proxy(Object.prototype, {"
+ context.eval(
+ LANGUAGE_ID,
+ "Object.setPrototypeOf(globalThis, new Proxy(Object.prototype, {"
+ " has(target, key) {"
+ " return key in __dsl || key in target;"
+ " },"
diff --git a/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/dsl/Components.java b/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/dsl/Components.java
index c6a462b..84a5610 100644
--- a/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/dsl/Components.java
+++ b/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/dsl/Components.java
@@ -20,7 +20,7 @@ import org.apache.camel.CamelContext;
import org.apache.camel.Component;
public class Components {
- private CamelContext context;
+ private final CamelContext context;
public Components(CamelContext context) {
this.context = context;
diff --git a/camel-k-loader-xml/src/main/java/org/apache/camel/k/loader/xml/XmlSourceLoader.java b/camel-k-loader-xml/src/main/java/org/apache/camel/k/loader/xml/XmlSourceLoader.java
index a2d3f8f..963c4bc 100644
--- a/camel-k-loader-xml/src/main/java/org/apache/camel/k/loader/xml/XmlSourceLoader.java
+++ b/camel-k-loader-xml/src/main/java/org/apache/camel/k/loader/xml/XmlSourceLoader.java
@@ -58,7 +58,7 @@ public class XmlSourceLoader implements SourceLoader {
LOGGER.debug("Loaded {} routes from {}", definitions.getRoutes().size(), source);
setRouteCollection(definitions);
}
- } catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException ignored) {
// ignore
} catch (XmlPullParserException e) {
LOGGER.debug("Unable to load RoutesDefinition: {}", e.getMessage());
@@ -73,7 +73,7 @@ public class XmlSourceLoader implements SourceLoader {
LOGGER.debug("Loaded {} rests from {}", definitions.getRests().size(), source);
setRestCollection(definitions);
}
- } catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException ignored) {
// ignore
} catch (XmlPullParserException e) {
LOGGER.debug("Unable to load RestsDefinition: {}", e.getMessage());
diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParserException.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParserException.java
index 08a39c6..5e63d61 100644
--- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParserException.java
+++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParserException.java
@@ -39,6 +39,10 @@ public class StepParserException extends RuntimeException {
this.properties = Arrays.asList(properties);
}
+ public String getProcessor() {
+ return processor;
+ }
+
public List<String> getProperties() {
return properties;
}
diff --git a/camel-k-main/camel-k-runtime-main/pom.xml b/camel-k-main/camel-k-runtime-main/pom.xml
index ad8438f..8b29cac 100644
--- a/camel-k-main/camel-k-runtime-main/pom.xml
+++ b/camel-k-main/camel-k-runtime-main/pom.xml
@@ -148,6 +148,11 @@
<artifactId>camel-k-runtime-knative</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-knative-test</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/camel-k-main/camel-k-runtime-main/src/main/java/org/apache/camel/k/main/ApplicationRuntime.java b/camel-k-main/camel-k-runtime-main/src/main/java/org/apache/camel/k/main/ApplicationRuntime.java
index fc67377..02551d8 100644
--- a/camel-k-main/camel-k-runtime-main/src/main/java/org/apache/camel/k/main/ApplicationRuntime.java
+++ b/camel-k-main/camel-k-runtime-main/src/main/java/org/apache/camel/k/main/ApplicationRuntime.java
@@ -149,6 +149,7 @@ public final class ApplicationRuntime implements Runtime {
@Override
public void configure(CamelContext context) {
+ // no-op
}
@Override
diff --git a/camel-k-main/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java b/camel-k-main/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java
index 59681e6..872de35 100644
--- a/camel-k-main/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java
+++ b/camel-k-main/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java
@@ -23,6 +23,7 @@ import org.apache.camel.Route;
import org.apache.camel.component.knative.KnativeComponent;
import org.apache.camel.component.knative.spi.Knative;
import org.apache.camel.component.knative.spi.KnativeEnvironment;
+import org.apache.camel.component.knative.test.KnativeEnvironmentSupport;
import org.apache.camel.k.Runtime;
import org.apache.camel.k.http.PlatformHttpServiceContextCustomizer;
import org.apache.camel.k.listener.ContextConfigurer;
@@ -115,7 +116,7 @@ public class RuntimeTest {
public void testLoadJavaSourceWrap() throws Exception {
KnativeComponent component = new KnativeComponent();
component.setEnvironment(KnativeEnvironment.on(
- KnativeEnvironment.endpoint(Knative.EndpointKind.sink, "sink", "localhost", AvailablePortFinder.getNextAvailable())
+ KnativeEnvironmentSupport.endpoint(Knative.EndpointKind.sink, "sink", "localhost", AvailablePortFinder.getNextAvailable())
));
PlatformHttpServiceContextCustomizer phsc = new PlatformHttpServiceContextCustomizer();
diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/java/org/apache/camel/k/quarkus/knative/deployment/Application.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/java/org/apache/camel/k/quarkus/knative/deployment/Application.java
index 43f74bb..279dcb1 100644
--- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/java/org/apache/camel/k/quarkus/knative/deployment/Application.java
+++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/java/org/apache/camel/k/quarkus/knative/deployment/Application.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.k.quarkus.knative.deployment;
+import java.util.Locale;
import java.util.Map;
import javax.enterprise.context.ApplicationScoped;
@@ -64,7 +65,7 @@ public class Application {
@Override
public void configure() throws Exception {
from("knative:endpoint/from")
- .transform().body(String.class, b -> b.toUpperCase());
+ .transform().body(String.class, b -> b.toUpperCase(Locale.US));
}
};
}
diff --git a/camel-k-quarkus/camel-k-runtime-quarkus/deployment/src/main/java/org/apache/camel/k/quarkus/deployment/DeploymentProcessor.java b/camel-k-quarkus/camel-k-runtime-quarkus/deployment/src/main/java/org/apache/camel/k/quarkus/deployment/DeploymentProcessor.java
index 3136a69..787f1cc 100644
--- a/camel-k-quarkus/camel-k-runtime-quarkus/deployment/src/main/java/org/apache/camel/k/quarkus/deployment/DeploymentProcessor.java
+++ b/camel-k-quarkus/camel-k-runtime-quarkus/deployment/src/main/java/org/apache/camel/k/quarkus/deployment/DeploymentProcessor.java
@@ -26,8 +26,6 @@ import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import org.apache.camel.k.Runtime;
import org.apache.camel.k.quarkus.ApplicationRecorder;
-import org.apache.camel.quarkus.core.deployment.spi.CamelServiceDestination;
-import org.apache.camel.quarkus.core.deployment.spi.CamelServicePatternBuildItem;
import org.apache.camel.quarkus.main.CamelMainApplication;
import org.apache.camel.quarkus.main.deployment.spi.CamelMainListenerBuildItem;
import org.apache.camel.spi.HasId;
diff --git a/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationListenerAdapter.java b/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationListenerAdapter.java
index 21b9321..9c15503 100644
--- a/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationListenerAdapter.java
+++ b/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationListenerAdapter.java
@@ -65,6 +65,7 @@ public class ApplicationListenerAdapter implements MainListener {
@Override
public void configure(CamelContext context) {
+ // no-op
}
@Override
@@ -103,20 +104,6 @@ public class ApplicationListenerAdapter implements MainListener {
});
}
- private static Runtime on(CamelContext context) {
- return new Runtime() {
- @Override
- public CamelContext getCamelContext() {
- return context;
- }
-
- @Override
- public void stop() throws Exception {
- Quarkus.asyncExit();
- }
- };
- }
-
private static Runtime on(BaseMainSupport main) {
return new Runtime() {
@Override
diff --git a/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationRuntimeConfigSourceProvider.java b/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationRuntimeConfigSourceProvider.java
index 7cbb9e8..302e0c8 100644
--- a/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationRuntimeConfigSourceProvider.java
+++ b/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationRuntimeConfigSourceProvider.java
@@ -23,12 +23,8 @@ import io.smallrye.config.PropertiesConfigSource;
import org.apache.camel.k.support.PropertiesSupport;
import org.eclipse.microprofile.config.spi.ConfigSource;
import org.eclipse.microprofile.config.spi.ConfigSourceProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class ApplicationRuntimeConfigSourceProvider implements ConfigSourceProvider {
- private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationRuntimeConfigSourceProvider.class);
-
@Override
public Iterable<ConfigSource> getConfigSources(ClassLoader forClassLoader) {
final Properties applicationProperties = PropertiesSupport.loadProperties();
diff --git a/camel-k-runtime-bom/pom.xml b/camel-k-runtime-bom/pom.xml
index bf665cc..760b9a5 100644
--- a/camel-k-runtime-bom/pom.xml
+++ b/camel-k-runtime-bom/pom.xml
@@ -131,6 +131,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-knative-test</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-maven-plugin</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/CompositeClassloader.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/CompositeClassloader.java
index 0719275..6387521 100644
--- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/CompositeClassloader.java
+++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/CompositeClassloader.java
@@ -23,6 +23,7 @@ public class CompositeClassloader extends ClassLoader {
private final List<ClassLoader> loaders = new CopyOnWriteArrayList<>();
public CompositeClassloader() {
+ // no parent
}
public CompositeClassloader(ClassLoader parent) {
@@ -38,8 +39,8 @@ public class CompositeClassloader extends ClassLoader {
for (ClassLoader loader: loaders) {
try {
return loader.loadClass(name);
- } catch (ClassNotFoundException e) {
- // ignore
+ } catch (ClassNotFoundException ignored) {
+ // ignored
}
}
diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/Sources.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/Sources.java
index 976d652..8cd0615 100644
--- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/Sources.java
+++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/Sources.java
@@ -67,7 +67,7 @@ public final class Sources {
this.language = language;
this.loader = loader;
this.interceptors = Collections.emptyList();
- this.content = content;
+ this.content = Arrays.copyOf(content, content.length);
}
public InMemory(String name, String language, String loader, List<String> interceptors, byte[] content) {
@@ -75,7 +75,7 @@ public final class Sources {
this.language = language;
this.loader = loader;
this.interceptors = new ArrayList<>(interceptors);
- this.content = content;
+ this.content = Arrays.copyOf(content, content.length);
}
@Override
@@ -113,7 +113,7 @@ public final class Sources {
private final String name;
private final String language;
private final String loader;
- private final List<String> interceptors;
+ private final String interceptors;
private final boolean compressed;
private URI(String uri) throws Exception {
@@ -125,12 +125,8 @@ public final class Sources {
final String query = StringSupport.substringAfter(uri, "?");
final Map<String, Object> params = URISupport.parseQuery(query);
- final String languageName = (String) params.get("language");
- final String compression = (String) params.get("compression");
- final String loader = (String) params.get("loader");
- final String interceptors = (String) params.get("interceptors");
- String language = languageName;
+ String language = (String) params.get("language");
if (ObjectHelper.isEmpty(language)) {
language = StringSupport.substringAfterLast(location, ":");
language = StringSupport.substringAfterLast(language, ".");
@@ -152,9 +148,9 @@ public final class Sources {
this.location = location;
this.name = name;
this.language = language;
- this.loader = loader;
- this.interceptors = interceptors != null ? Arrays.asList(interceptors.split(",", -1)) : Collections.emptyList();
- this.compressed = Boolean.parseBoolean(compression);
+ this.loader = (String) params.get("loader");
+ this.interceptors = (String) params.get("interceptors");
+ this.compressed = Boolean.parseBoolean((String) params.get("compression"));
}
@Override
@@ -174,7 +170,7 @@ public final class Sources {
@Override
public List<String> getInterceptors() {
- return interceptors;
+ return interceptors != null ? Arrays.asList(interceptors.split(",", -1)) : Collections.emptyList();
}
@Override
diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java
index c701621..c74b5b8 100644
--- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java
+++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java
@@ -53,7 +53,7 @@ public class RoutesConfigurer extends AbstractPhaseListener {
load(runtime, routes.split(",", -1));
}
- protected void load(Runtime runtime, String[] routes) {
+ protected void load(Runtime runtime, String... routes) {
for (String route: routes) {
if (ObjectHelper.isEmpty(route)) {
continue;
diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/KubernetesPropertiesFunction.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/KubernetesPropertiesFunction.java
index e66c5b1..067d5f0 100644
--- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/KubernetesPropertiesFunction.java
+++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/KubernetesPropertiesFunction.java
@@ -21,6 +21,7 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Locale;
import org.apache.camel.spi.PropertiesFunction;
import org.apache.camel.util.StringHelper;
@@ -54,7 +55,7 @@ public class KubernetesPropertiesFunction implements PropertiesFunction {
return defaultValue;
}
- Path file = this.root.resolve(name.toLowerCase()).resolve(property);
+ Path file = this.root.resolve(name.toLowerCase(Locale.US)).resolve(property);
if (Files.exists(file) && !Files.isDirectory(file)) {
try {
return Files.readString(file, StandardCharsets.UTF_8);
diff --git a/camel-k-runtime-cron/src/main/java/org/apache/camel/k/cron/CronSourceLoaderInterceptor.java b/camel-k-runtime-cron/src/main/java/org/apache/camel/k/cron/CronSourceLoaderInterceptor.java
index e97eaee..2eb29d4 100644
--- a/camel-k-runtime-cron/src/main/java/org/apache/camel/k/cron/CronSourceLoaderInterceptor.java
+++ b/camel-k-runtime-cron/src/main/java/org/apache/camel/k/cron/CronSourceLoaderInterceptor.java
@@ -73,6 +73,7 @@ public class CronSourceLoaderInterceptor implements SourceLoader.Interceptor, Ru
@Override
public void beforeLoad(SourceLoader loader, Source source) {
+ // no-op
}
@Override
@@ -111,7 +112,7 @@ public class CronSourceLoaderInterceptor implements SourceLoader.Interceptor, Ru
};
}
- private static boolean shouldBeOverridden(String uri, String[] components) {
+ private static boolean shouldBeOverridden(String uri, String... components) {
if (uri == null) {
return false;
}
diff --git a/camel-k-runtime-http/src/main/java/org/apache/camel/k/http/PlatformHttpServiceContextCustomizer.java b/camel-k-runtime-http/src/main/java/org/apache/camel/k/http/PlatformHttpServiceContextCustomizer.java
index d753c0e..2a532b3 100644
--- a/camel-k-runtime-http/src/main/java/org/apache/camel/k/http/PlatformHttpServiceContextCustomizer.java
+++ b/camel-k-runtime-http/src/main/java/org/apache/camel/k/http/PlatformHttpServiceContextCustomizer.java
@@ -29,9 +29,6 @@ import org.apache.camel.k.annotation.Customizer;
@Customizer("platform-http")
public class PlatformHttpServiceContextCustomizer extends VertxPlatformHttpServerConfiguration implements ContextCustomizer {
- public PlatformHttpServiceContextCustomizer() {
- }
-
@Override
public int getOrder() {
return Ordered.HIGHEST;
diff --git a/camel-k-runtime-knative/pom.xml b/camel-k-runtime-knative/pom.xml
index 6a27cd8..5d7a482 100644
--- a/camel-k-runtime-knative/pom.xml
+++ b/camel-k-runtime-knative/pom.xml
@@ -65,6 +65,11 @@
<artifactId>camel-k-test</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-knative-test</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.apache.camel.k</groupId>
diff --git a/camel-k-runtime-knative/src/main/java/org/apache/camel/k/loader/knative/KnativeSourceLoaderInterceptor.java b/camel-k-runtime-knative/src/main/java/org/apache/camel/k/loader/knative/KnativeSourceLoaderInterceptor.java
index ef303b8..160399c 100644
--- a/camel-k-runtime-knative/src/main/java/org/apache/camel/k/loader/knative/KnativeSourceLoaderInterceptor.java
+++ b/camel-k-runtime-knative/src/main/java/org/apache/camel/k/loader/knative/KnativeSourceLoaderInterceptor.java
@@ -36,6 +36,7 @@ public class KnativeSourceLoaderInterceptor implements SourceLoader.Interceptor
@Override
public void beforeLoad(SourceLoader loader, Source source) {
+ // no-op
}
@Override
diff --git a/camel-k-runtime-knative/src/test/java/org/apache/camel/k/loader/knative/KnativeSourceRoutesLoaderTest.java b/camel-k-runtime-knative/src/test/java/org/apache/camel/k/loader/knative/KnativeSourceRoutesLoaderTest.java
index 513005e..4a6e49c 100644
--- a/camel-k-runtime-knative/src/test/java/org/apache/camel/k/loader/knative/KnativeSourceRoutesLoaderTest.java
+++ b/camel-k-runtime-knative/src/test/java/org/apache/camel/k/loader/knative/KnativeSourceRoutesLoaderTest.java
@@ -18,10 +18,7 @@ package org.apache.camel.k.loader.knative;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
-import java.util.Map;
-import java.util.Properties;
import java.util.UUID;
import java.util.stream.Stream;
@@ -30,10 +27,9 @@ import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.knative.KnativeComponent;
import org.apache.camel.component.knative.KnativeConstants;
-import org.apache.camel.component.knative.spi.CloudEvent;
-import org.apache.camel.component.knative.spi.CloudEvents;
import org.apache.camel.component.knative.spi.Knative;
import org.apache.camel.component.knative.spi.KnativeEnvironment;
+import org.apache.camel.component.knative.test.KnativeEnvironmentSupport;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.k.Runtime;
@@ -77,7 +73,7 @@ public class KnativeSourceRoutesLoaderTest {
KnativeComponent component = new KnativeComponent();
component.setEnvironment(KnativeEnvironment.on(
- KnativeEnvironment.endpoint(Knative.EndpointKind.sink, "sink", "localhost", runtime.port)
+ KnativeEnvironmentSupport.endpoint(Knative.EndpointKind.sink, "sink", "localhost", runtime.port)
));
CamelContext context = runtime.getCamelContext();
diff --git a/camel-knative/camel-knative-api/src/main/java/org/apache/camel/component/knative/spi/KnativeEnvironment.java b/camel-knative/camel-knative-api/src/main/java/org/apache/camel/component/knative/spi/KnativeEnvironment.java
index cfca7dc..1703fda 100644
--- a/camel-knative/camel-knative-api/src/main/java/org/apache/camel/component/knative/spi/KnativeEnvironment.java
+++ b/camel-knative/camel-knative-api/src/main/java/org/apache/camel/component/knative/spi/KnativeEnvironment.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.knative.spi;
+import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
@@ -63,13 +64,13 @@ public class KnativeEnvironment {
//
// ************************
- public static KnativeEnvironment mandatoryLoadFromSerializedString(CamelContext context, String configuration) throws Exception {
+ public static KnativeEnvironment mandatoryLoadFromSerializedString(CamelContext context, String configuration) throws IOException {
try (Reader reader = new StringReader(configuration)) {
return Knative.MAPPER.readValue(reader, KnativeEnvironment.class);
}
}
- public static KnativeEnvironment mandatoryLoadFromResource(CamelContext context, String path) throws Exception {
+ public static KnativeEnvironment mandatoryLoadFromResource(CamelContext context, String path) throws IOException {
try (InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(context, path)) {
//
// read the knative environment from a file formatted as json, i.e. :
@@ -99,84 +100,6 @@ public class KnativeEnvironment {
}
}
- public static KnativeServiceDefinition endpoint(Knative.EndpointKind endpointKind, String name, String host, int port) {
- return serviceBuilder(Knative.Type.endpoint, name)
- .withHost(host)
- .withPort(port)
- .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind)
- .build();
- }
-
- public static KnativeServiceDefinition endpoint(Knative.EndpointKind endpointKind, String name, String host, int port, Map<String, String> metadata) {
- return serviceBuilder(Knative.Type.endpoint, name)
- .withHost(host)
- .withPort(port)
- .withMeta(metadata)
- .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind)
- .build();
- }
-
- public static KnativeServiceDefinition sourceEndpoint(String name, Map<String, String> metadata) {
- return serviceBuilder(Knative.Type.endpoint, name)
- .withMeta(metadata)
- .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.source.name())
- .build();
- }
-
- public static KnativeServiceDefinition channel(Knative.EndpointKind endpointKind, String name, String host, int port) {
- return serviceBuilder(Knative.Type.channel, name)
- .withHost(host)
- .withPort(port)
- .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind)
- .build();
- }
-
- public static KnativeServiceDefinition channel(Knative.EndpointKind endpointKind, String name, String host, int port, Map<String, String> metadata) {
- return serviceBuilder(Knative.Type.channel, name)
- .withHost(host)
- .withPort(port)
- .withMeta(metadata)
- .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind)
- .build();
- }
-
- public static KnativeServiceDefinition sourceChannel(String name, Map<String, String> metadata) {
- return serviceBuilder(Knative.Type.channel, name)
- .withMeta(metadata)
- .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.source)
- .build();
- }
-
- public static KnativeServiceDefinition event(Knative.EndpointKind endpointKind, String name, String host, int port) {
- return serviceBuilder(Knative.Type.event, name)
- .withHost(host)
- .withPort(port)
- .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind)
- .build();
- }
-
- public static KnativeServiceDefinition sourceEvent(String name) {
- return serviceBuilder(Knative.Type.event, name)
- .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.source)
- .build();
- }
-
- public static KnativeServiceDefinition sourceEvent(String name, Map<String, String> metadata) {
- return serviceBuilder(Knative.Type.event, name)
- .withMeta(metadata)
- .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.source)
- .build();
- }
-
- public static KnativeServiceDefinition event(Knative.EndpointKind endpointKind, String name, String host, int port, Map<String, String> metadata) {
- return serviceBuilder(Knative.Type.event, name)
- .withHost(host)
- .withPort(port)
- .withMeta(metadata)
- .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind)
- .build();
- }
-
public static KnativeEnvironment on(KnativeServiceDefinition... definitions) {
return new KnativeEnvironment(Arrays.asList(definitions));
}
diff --git a/camel-knative/camel-knative-http/pom.xml b/camel-knative/camel-knative-http/pom.xml
index 098c303..801d74c 100644
--- a/camel-knative/camel-knative-http/pom.xml
+++ b/camel-knative/camel-knative-http/pom.xml
@@ -76,6 +76,11 @@
<artifactId>camel-knative</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-knative-test</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
diff --git a/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpProducer.java b/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpProducer.java
index ca23300..f76d1c8 100644
--- a/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpProducer.java
+++ b/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpProducer.java
@@ -183,7 +183,7 @@ public class KnativeHttpProducer extends DefaultAsyncProducer {
int port = definition.getPortOrDefault(KnativeHttpTransport.DEFAULT_PORT);
String path = definition.getPathOrDefault(KnativeHttpTransport.DEFAULT_PATH);
- if (!path.startsWith("/")) {
+ if (path.charAt(0) != '/') {
path = "/" + path;
}
diff --git a/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpSupport.java b/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpSupport.java
index 67bb64f..83995a9 100644
--- a/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpSupport.java
+++ b/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpSupport.java
@@ -56,7 +56,7 @@ public final class KnativeHttpSupport {
.filter(e -> e.getKey().startsWith(Knative.KNATIVE_FILTER_PREFIX))
.collect(Collectors.toMap(
e -> e.getKey().substring(Knative.KNATIVE_FILTER_PREFIX.length()),
- e -> e.getValue()
+ Map.Entry::getValue
));
return v -> {
@@ -66,8 +66,6 @@ public final class KnativeHttpSupport {
for (Map.Entry<String, String> entry : filters.entrySet()) {
final List<String> values = v.headers().getAll(entry.getKey());
- final String ref = entry.getValue();
-
if (values.isEmpty()) {
return false;
}
@@ -80,7 +78,7 @@ public final class KnativeHttpSupport {
val = val.trim();
}
- boolean matches = Objects.equals(ref, val) || val.matches(ref);
+ boolean matches = Objects.equals(entry.getValue(), val) || val.matches(entry.getValue());
if (!matches) {
return false;
}
diff --git a/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpTransport.java b/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpTransport.java
index a9b0613..fc51004 100644
--- a/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpTransport.java
+++ b/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpTransport.java
@@ -37,9 +37,6 @@ public class KnativeHttpTransport extends ServiceSupport implements CamelContext
private WebClientOptions vertxHttpClientOptions;
private CamelContext camelContext;
- public KnativeHttpTransport() {
- }
-
public VertxPlatformHttpRouter getRouter() {
return router;
}
@@ -81,6 +78,7 @@ public class KnativeHttpTransport extends ServiceSupport implements CamelContext
@Override
protected void doStop() throws Exception {
+ // no-op
}
// *****************************
diff --git a/camel-knative/camel-knative-http/src/test/java/org/apache/camel/component/knative/http/KnativeHttpTest.java b/camel-knative/camel-knative-http/src/test/java/org/apache/camel/component/knative/http/KnativeHttpTest.java
index 63e18cb..b61418f 100644
--- a/camel-knative/camel-knative-http/src/test/java/org/apache/camel/component/knative/http/KnativeHttpTest.java
+++ b/camel-knative/camel-knative-http/src/test/java/org/apache/camel/component/knative/http/KnativeHttpTest.java
@@ -58,12 +58,12 @@ import static io.restassured.RestAssured.given;
import static io.restassured.config.EncoderConfig.encoderConfig;
import static org.apache.camel.component.knative.http.KnativeHttpTestSupport.configureKnativeComponent;
import static org.apache.camel.component.knative.http.KnativeHttpTestSupport.httpAttribute;
-import static org.apache.camel.component.knative.spi.KnativeEnvironment.channel;
-import static org.apache.camel.component.knative.spi.KnativeEnvironment.endpoint;
-import static org.apache.camel.component.knative.spi.KnativeEnvironment.event;
-import static org.apache.camel.component.knative.spi.KnativeEnvironment.sourceChannel;
-import static org.apache.camel.component.knative.spi.KnativeEnvironment.sourceEndpoint;
-import static org.apache.camel.component.knative.spi.KnativeEnvironment.sourceEvent;
+import static org.apache.camel.component.knative.test.KnativeEnvironmentSupport.channel;
+import static org.apache.camel.component.knative.test.KnativeEnvironmentSupport.endpoint;
+import static org.apache.camel.component.knative.test.KnativeEnvironmentSupport.event;
+import static org.apache.camel.component.knative.test.KnativeEnvironmentSupport.sourceChannel;
+import static org.apache.camel.component.knative.test.KnativeEnvironmentSupport.sourceEndpoint;
+import static org.apache.camel.component.knative.test.KnativeEnvironmentSupport.sourceEvent;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.emptyOrNullString;
import static org.hamcrest.Matchers.is;
diff --git a/camel-knative/pom.xml b/camel-knative/camel-knative-test/pom.xml
similarity index 80%
copy from camel-knative/pom.xml
copy to camel-knative/camel-knative-test/pom.xml
index 62b7d10..5d70acc 100644
--- a/camel-knative/pom.xml
+++ b/camel-knative/camel-knative-test/pom.xml
@@ -20,19 +20,20 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-runtime-parent</artifactId>
+ <artifactId>camel-knative-parent</artifactId>
<version>1.5.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <packaging>pom</packaging>
- <artifactId>camel-knative-parent</artifactId>
+ <artifactId>camel-knative-test</artifactId>
+ <dependencies>
- <modules>
- <module>camel-knative-api</module>
- <module>camel-knative</module>
- <module>camel-knative-http</module>
- </modules>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-knative-api</artifactId>
+ </dependency>
+
+ </dependencies>
</project>
diff --git a/camel-knative/camel-knative-test/src/main/java/org/apache/camel/component/knative/test/KnativeEnvironmentSupport.java b/camel-knative/camel-knative-test/src/main/java/org/apache/camel/component/knative/test/KnativeEnvironmentSupport.java
new file mode 100644
index 0000000..e775b9d
--- /dev/null
+++ b/camel-knative/camel-knative-test/src/main/java/org/apache/camel/component/knative/test/KnativeEnvironmentSupport.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.knative.test;
+
+import java.util.Map;
+
+import org.apache.camel.component.knative.spi.Knative;
+import org.apache.camel.component.knative.spi.KnativeEnvironment;
+
+public final class KnativeEnvironmentSupport {
+ private KnativeEnvironmentSupport() {
+ }
+
+ public static KnativeEnvironment.KnativeServiceDefinition endpoint(Knative.EndpointKind endpointKind, String name, String host, int port) {
+ return KnativeEnvironment.serviceBuilder(Knative.Type.endpoint, name)
+ .withHost(host)
+ .withPort(port)
+ .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind)
+ .build();
+ }
+
+ public static KnativeEnvironment.KnativeServiceDefinition endpoint(Knative.EndpointKind endpointKind, String name, String host, int port, Map<String, String> metadata) {
+ return KnativeEnvironment.serviceBuilder(Knative.Type.endpoint, name)
+ .withHost(host)
+ .withPort(port)
+ .withMeta(metadata)
+ .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind)
+ .build();
+ }
+
+ public static KnativeEnvironment.KnativeServiceDefinition sourceEndpoint(String name, Map<String, String> metadata) {
+ return KnativeEnvironment.serviceBuilder(Knative.Type.endpoint, name)
+ .withMeta(metadata)
+ .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.source.name())
+ .build();
+ }
+
+ public static KnativeEnvironment.KnativeServiceDefinition channel(Knative.EndpointKind endpointKind, String name, String host, int port) {
+ return KnativeEnvironment.serviceBuilder(Knative.Type.channel, name)
+ .withHost(host)
+ .withPort(port)
+ .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind)
+ .build();
+ }
+
+ public static KnativeEnvironment.KnativeServiceDefinition channel(Knative.EndpointKind endpointKind, String name, String host, int port, Map<String, String> metadata) {
+ return KnativeEnvironment.serviceBuilder(Knative.Type.channel, name)
+ .withHost(host)
+ .withPort(port)
+ .withMeta(metadata)
+ .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind)
+ .build();
+ }
+
+ public static KnativeEnvironment.KnativeServiceDefinition sourceChannel(String name, Map<String, String> metadata) {
+ return KnativeEnvironment.serviceBuilder(Knative.Type.channel, name)
+ .withMeta(metadata)
+ .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.source)
+ .build();
+ }
+
+ public static KnativeEnvironment.KnativeServiceDefinition event(Knative.EndpointKind endpointKind, String name, String host, int port) {
+ return KnativeEnvironment.serviceBuilder(Knative.Type.event, name)
+ .withHost(host)
+ .withPort(port)
+ .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind)
+ .build();
+ }
+
+ public static KnativeEnvironment.KnativeServiceDefinition sourceEvent(String name) {
+ return KnativeEnvironment.serviceBuilder(Knative.Type.event, name)
+ .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.source)
+ .build();
+ }
+
+ public static KnativeEnvironment.KnativeServiceDefinition sourceEvent(String name, Map<String, String> metadata) {
+ return KnativeEnvironment.serviceBuilder(Knative.Type.event, name)
+ .withMeta(metadata)
+ .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.source)
+ .build();
+ }
+
+ public static KnativeEnvironment.KnativeServiceDefinition event(Knative.EndpointKind endpointKind, String name, String host, int port, Map<String, String> metadata) {
+ return KnativeEnvironment.serviceBuilder(Knative.Type.event, name)
+ .withHost(host)
+ .withPort(port)
+ .withMeta(metadata)
+ .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind)
+ .build();
+ }
+}
diff --git a/camel-knative/camel-knative/pom.xml b/camel-knative/camel-knative/pom.xml
index d68e9ae..29f2bdd 100644
--- a/camel-knative/camel-knative/pom.xml
+++ b/camel-knative/camel-knative/pom.xml
@@ -74,6 +74,11 @@
<artifactId>camel-k-test</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-knative-test</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
diff --git a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java
index ee5f168..d863be5 100644
--- a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java
+++ b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java
@@ -52,7 +52,7 @@ public class KnativeComponent extends DefaultComponent {
@Metadata
private Map<String, Object> transportOptions;
- private boolean managedTransport = true;
+ private boolean managedTransport;
public KnativeComponent() {
this(null);
@@ -168,6 +168,12 @@ public class KnativeComponent extends DefaultComponent {
.getFactoryFinder(Knative.KNATIVE_TRANSPORT_RESOURCE_PATH)
.newInstance(protocol.name(), KnativeTransport.class)
.orElseThrow(() -> new RuntimeException("Error creating knative transport for protocol: " + protocol.name()));
+
+ if (transportOptions != null) {
+ setProperties(transport, new HashMap<>(transportOptions));
+ }
+
+ this.managedTransport = true;
}
}
diff --git a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java
index 0e2b235..30547ba 100644
--- a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java
+++ b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java
@@ -50,9 +50,6 @@ public class KnativeConfiguration implements Cloneable {
@UriParam(label = "consumer,advanced", defaultValue = "true")
private Boolean reply;
- public KnativeConfiguration() {
- }
-
// ************************
//
// Properties
diff --git a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java
index 3de7929..b846cc8 100644
--- a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java
+++ b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java
@@ -219,15 +219,16 @@ public class KnativeEndpoint extends DefaultEndpoint {
private Predicate<KnativeEnvironment.KnativeServiceDefinition> serviceFilter(Knative.EndpointKind endpointKind) {
return s -> {
final String type = s.getMetadata(Knative.CAMEL_ENDPOINT_KIND);
- final String apiv = s.getMetadata(Knative.KNATIVE_API_VERSION);
- final String kind = s.getMetadata(Knative.KNATIVE_KIND);
-
if (!Objects.equals(endpointKind.name(), type)) {
return false;
}
+
+ final String apiv = s.getMetadata(Knative.KNATIVE_API_VERSION);
if (configuration.getApiVersion() != null && !Objects.equals(apiv, configuration.getApiVersion())) {
return false;
}
+
+ final String kind = s.getMetadata(Knative.KNATIVE_KIND);
if (configuration.getKind() != null && !Objects.equals(kind, configuration.getKind())) {
return false;
}
diff --git a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/ce/CloudEventProcessors.java b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/ce/CloudEventProcessors.java
index 96e891d..fe13c02 100644
--- a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/ce/CloudEventProcessors.java
+++ b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/ce/CloudEventProcessors.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.knative.ce;
+import java.util.Locale;
import java.util.Map;
import java.util.Objects;
@@ -83,7 +84,7 @@ public enum CloudEventProcessors implements CloudEventProcessor {
// Map every remaining field as it is (extensions).
//
content.forEach((key, val) -> {
- message.setHeader(key.toLowerCase(), val);
+ message.setHeader(key.toLowerCase(Locale.US), val);
});
}
@@ -114,7 +115,7 @@ public enum CloudEventProcessors implements CloudEventProcessor {
// Map every remaining field as it is (extensions).
//
content.forEach((key, val) -> {
- message.setHeader(key.toLowerCase(), val);
+ message.setHeader(key.toLowerCase(Locale.US), val);
});
}
}),
@@ -141,7 +142,7 @@ public enum CloudEventProcessors implements CloudEventProcessor {
// Map every remaining field as it is (extensions).
//
content.forEach((key, val) -> {
- message.setHeader(key.toLowerCase(), val);
+ message.setHeader(key.toLowerCase(Locale.US), val);
});
}
});
diff --git a/camel-knative/camel-knative/src/test/java/org/apache/camel/component/knative/KnativeComponentTest.java b/camel-knative/camel-knative/src/test/java/org/apache/camel/component/knative/KnativeComponentTest.java
index ac6ed7a..74272c5 100644
--- a/camel-knative/camel-knative/src/test/java/org/apache/camel/component/knative/KnativeComponentTest.java
+++ b/camel-knative/camel-knative/src/test/java/org/apache/camel/component/knative/KnativeComponentTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.knative;
import org.apache.camel.CamelContext;
import org.apache.camel.component.knative.spi.Knative;
import org.apache.camel.component.knative.spi.KnativeEnvironment;
+import org.apache.camel.component.knative.test.KnativeEnvironmentSupport;
import org.apache.camel.impl.DefaultCamelContext;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@@ -67,8 +68,8 @@ public class KnativeComponentTest {
component.setEnvironment(env);
component.setTransport(new KnativeTransportNoop());
- context.getRegistry().bind("ereg", KnativeEnvironment.endpoint(Knative.EndpointKind.source, "ereg", null, -1));
- context.getRegistry().bind("creg", KnativeEnvironment.channel(Knative.EndpointKind.source, "creg", null, -1));
+ context.getRegistry().bind("ereg", KnativeEnvironmentSupport.endpoint(Knative.EndpointKind.source, "ereg", null, -1));
+ context.getRegistry().bind("creg", KnativeEnvironmentSupport.channel(Knative.EndpointKind.source, "creg", null, -1));
context.addComponent("knative", component);
//
diff --git a/camel-knative/pom.xml b/camel-knative/pom.xml
index 62b7d10..e5b405c 100644
--- a/camel-knative/pom.xml
+++ b/camel-knative/pom.xml
@@ -31,6 +31,7 @@
<modules>
<module>camel-knative-api</module>
+ <module>camel-knative-test</module>
<module>camel-knative</module>
<module>camel-knative-http</module>
</modules>
diff --git a/pom.xml b/pom.xml
index ccacb1a..1f3d3d0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -93,6 +93,7 @@
<maven-enforcer-plugin.version>1.4.1</maven-enforcer-plugin.version>
<maven-resources-plugin.version>3.2.0</maven-resources-plugin.version>
<maven-site-plugin.version>3.9.0</maven-site-plugin.version>
+ <maven-pmd-plugin.version>3.13.0</maven-pmd-plugin.version>
</properties>
<developers>
@@ -228,8 +229,67 @@
</dependency>
</dependencies>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <version>${maven-pmd-plugin.version}</version>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>versions-maven-plugin</artifactId>
+ <version>${versions-maven-plugin.version}</version>
+ </plugin>
+ <plugin>
+ <groupId>org.commonjava.maven.plugins</groupId>
+ <artifactId>directory-maven-plugin</artifactId>
+ <version>${directory-maven-plugin.version}</version>
+ </plugin>
+ <plugin>
+ <groupId>com.mycila</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <version>${mycila-license.version}</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-gpg-plugin</artifactId>
+ <version>${maven-gpg-plugin.version}</version>
+ </plugin>
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>${maven-deploy-plugin.version}</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>${maven-source-plugin.version}</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>${maven-javadoc-plugin.version}</version>
+ </plugin>
</plugins>
</pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.commonjava.maven.plugins</groupId>
+ <artifactId>directory-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>directories</id>
+ <goals>
+ <goal>highest-basedir</goal>
+ </goals>
+ <phase>initialize</phase>
+ <configuration>
+ <property>camel-k.project.root</property>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
</build>
<modules>
@@ -337,6 +397,11 @@
<artifactId>camel-knative-http</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-knative-test</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- runtime -->
<dependency>
@@ -622,26 +687,8 @@
<defaultGoal>initialize versions:display-dependency-updates</defaultGoal>
<plugins>
<plugin>
- <groupId>org.commonjava.maven.plugins</groupId>
- <artifactId>directory-maven-plugin</artifactId>
- <version>${directory-maven-plugin.version}</version>
- <executions>
- <execution>
- <id>directories</id>
- <goals>
- <goal>highest-basedir</goal>
- </goals>
- <phase>initialize</phase>
- <configuration>
- <property>camel-k.project.root</property>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
- <version>${versions-maven-plugin.version}</version>
<configuration>
<rulesUri>file:///${camel-k.project.root}/.maven-versions-rules.xml</rulesUri>
</configuration>
@@ -694,12 +741,10 @@
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
- <version>${maven-deploy-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
- <version>${maven-source-plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
@@ -712,7 +757,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>${maven-javadoc-plugin.version}</version>
<executions>
<execution>
<id>attach-javadocs</id>
@@ -730,7 +774,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
- <version>${maven-gpg-plugin.version}</version>
<configuration>
<passphrase>${gpg.passphrase}</passphrase>
<useAgent>${gpg.useagent}</useAgent>
@@ -763,7 +806,6 @@
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
- <version>${mycila-license.version}</version>
<configuration>
<header>header.txt</header>
<excludes>
@@ -817,6 +859,37 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>pmd</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <rulesets>
+ <ruleset>file:///${camel-k.project.root}/tooling/pmd-ruleset.xml</ruleset>
+ </rulesets>
+ <analysisCache>false</analysisCache>
+ <printFailingErrors>true</printFailingErrors>
+ <failOnViolation>true</failOnViolation>
+ <linkXRef>false</linkXRef>
+ <excludeRoots>
+ <excludeRoot>${project.basedir}/src/generated</excludeRoot>
+ <excludeRoot>${project.build.directory}/generated-sources</excludeRoot>
+ </excludeRoots>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
<profile>
<id>docker</id>
diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
index 7a37ec8..a6d3233 100644
--- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
+++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
@@ -17,16 +17,14 @@
package org.apache.camel.k.tooling.maven;
import java.io.IOException;
-import java.io.InputStream;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Comparator;
-import java.util.Properties;
+import java.util.Locale;
import java.util.ServiceLoader;
-import java.util.function.Consumer;
import java.util.stream.StreamSupport;
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -44,6 +42,7 @@ import org.apache.camel.k.tooling.maven.model.crd.CamelCatalog;
import org.apache.camel.k.tooling.maven.model.crd.CamelCatalogSpec;
import org.apache.camel.k.tooling.maven.model.crd.RuntimeSpec;
import org.apache.camel.k.tooling.maven.model.k8s.ObjectMeta;
+import org.apache.camel.k.tooling.maven.support.MavenSupport;
import org.apache.camel.quarkus.core.FastCamelContext;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -94,26 +93,23 @@ public class GenerateCatalogMojo extends AbstractMojo {
}
final org.apache.camel.catalog.CamelCatalog catalog = new DefaultCamelCatalog();
- final String runtimeVersion = getVersion(getClass(), "/META-INF/maven/org.apache.camel.k/camel-k-maven-plugin/pom.properties");
- final String catalogName = String.format("camel-catalog-%s-%s", runtimeVersion.toLowerCase(), runtime);
+ final String runtimeVersion = MavenSupport.getVersion(getClass(), "/META-INF/maven/org.apache.camel.k/camel-k-maven-plugin/pom.properties");
+ final String catalogName = String.format("camel-catalog-%s-%s", runtimeVersion.toLowerCase(Locale.US), runtime);
try {
- ServiceLoader<CatalogProcessor> processors = ServiceLoader.load(CatalogProcessor.class);
- Comparator<CatalogProcessor> comparator = Comparator.comparingInt(CatalogProcessor::getOrder);
-
RuntimeSpec.Builder runtimeSpec = new RuntimeSpec.Builder()
.version(runtimeVersion)
.provider(runtime);
- getVersion(
+ MavenSupport.getVersion(
AbstractCamelContext.class,
"org.apache.camel", "camel-base",
version -> runtimeSpec.putMetadata("camel.version", version));
- getVersion(
+ MavenSupport.getVersion(
FastCamelContext.class,
"io.quarkus", "quarkus-core",
version -> runtimeSpec.putMetadata("quarkus.version", version));
- getVersion(
+ MavenSupport.getVersion(
QuarkusRuntimeProvider.class,
"org.apache.camel.quarkus", "camel-quarkus-catalog",
version -> runtimeSpec.putMetadata("camel-quarkus.version", version));
@@ -188,11 +184,11 @@ public class GenerateCatalogMojo extends AbstractMojo {
CamelCatalogSpec.Builder catalogSpec = new CamelCatalogSpec.Builder()
.runtime(runtimeSpec.build());
- StreamSupport.stream(processors.spliterator(), false).sorted(comparator).filter(p -> p.accepts(catalog)).forEach(p -> {
- getLog().info("Executing processor: " + p.getClass().getName());
- p.process(project, catalog, catalogSpec);
- });
+ StreamSupport.stream(ServiceLoader.load(CatalogProcessor.class).spliterator(), false)
+ .sorted(Comparator.comparingInt(CatalogProcessor::getOrder))
+ .filter(p -> p.accepts(catalog))
+ .forEach(p -> p.process(project, catalog, catalogSpec));
ObjectMeta.Builder metadata = new ObjectMeta.Builder()
.name(catalogName)
@@ -250,54 +246,4 @@ public class GenerateCatalogMojo extends AbstractMojo {
throw new MojoExecutionException("Exception while generating catalog", e);
}
}
-
- private static void getVersion(Class<?> clazz, String path, Consumer<String> consumer) {
- consumer.accept(getVersion(clazz, path));
- }
-
- private static void getVersion(Class<?> clazz, String groupId, String artifactId, Consumer<String> consumer) {
- getVersion(
- clazz,
- String.format("/META-INF/maven/%s/%s/pom.properties", groupId, artifactId),
- consumer);
- }
-
- private static synchronized String getVersion(Class<?> clazz, String groupId, String artifactId) {
- return getVersion(
- clazz,
- String.format("/META-INF/maven/%s/%s/pom.properties", groupId, artifactId));
- }
-
- private static synchronized String getVersion(Class<?> clazz, String path) {
- String version = null;
-
- // try to load from maven properties first
- try (InputStream is = clazz.getResourceAsStream(path)) {
- if (is != null) {
- Properties p = new Properties();
- p.load(is);
- version = p.getProperty("version", "");
- }
- } catch (Exception e) {
- // ignore
- }
-
- // fallback to using Java API
- if (version == null) {
- Package aPackage = clazz.getPackage();
- if (aPackage != null) {
- version = aPackage.getImplementationVersion();
- if (version == null) {
- version = aPackage.getSpecificationVersion();
- }
- }
- }
-
- if (version == null) {
- // we could not compute the version so use a blank
- throw new IllegalStateException("Unable to determine runtime version");
- }
-
- return version;
- }
}
diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateRestXML.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateRestXML.java
index 67d6bae..82eb546 100644
--- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateRestXML.java
+++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateRestXML.java
@@ -47,11 +47,6 @@ import org.apache.maven.plugins.annotations.ResolutionScope;
threadSafe = true,
requiresProject = false)
class GenerateRestXML extends AbstractMojo {
- private static final String[] YAML_EXTENSIONS = {
- "yaml",
- "yml"
- };
-
@Parameter(property = "openapi.spec")
private String inputFile;
@Parameter(property = "dsl.out")
@@ -102,10 +97,8 @@ class GenerateRestXML extends AbstractMojo {
final CamelContext context = new DefaultCamelContext();
final String dsl = RestDslXmlGenerator.toXml(document).generate(context);
- try {
+ try (writer) {
writer.write(dsl);
- } finally {
- writer.close();
}
} catch (Exception e) {
throw new MojoExecutionException("Exception while generating rest xml", e);
diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlLoaderSupportClasses.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlLoaderSupportClasses.java
index 947a08c..b71c8c7 100644
--- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlLoaderSupportClasses.java
+++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlLoaderSupportClasses.java
@@ -73,7 +73,7 @@ public class GenerateYamlLoaderSupportClasses extends GenerateYamlSupport {
.build()
.writeTo(Paths.get(output));
} catch (IOException e) {
- throw new MojoFailureException(e.getMessage());
+ throw new MojoFailureException(e.getMessage(), e);
}
}
@@ -181,12 +181,10 @@ public class GenerateYamlLoaderSupportClasses extends GenerateYamlSupport {
.forEach(
i -> {
AnnotationValue id = i.classAnnotation(YAML_STEP_PARSER_ANNOTATION).value("id");
- if (id != null) {
- if (ids.add(id.asString())) {
- mb.beginControlFlow("case $S:", id.asString());
- mb.addStatement("return new $L()", i.name().toString());
- mb.endControlFlow();
- }
+ if (id != null && ids.add(id.asString())) {
+ mb.beginControlFlow("case $S:", id.asString());
+ mb.addStatement("return new $L()", i.name().toString());
+ mb.endControlFlow();
}
AnnotationValue aliases = i.classAnnotation(YAML_STEP_PARSER_ANNOTATION).value("aliases");
@@ -209,31 +207,35 @@ public class GenerateYamlLoaderSupportClasses extends GenerateYamlSupport {
AnnotationInstance meta = i.classAnnotation(METADATA_ANNOTATION);
AnnotationInstance root = i.classAnnotation(XML_ROOT_ELEMENT_ANNOTATION_CLASS);
- if (meta != null && root != null) {
- AnnotationValue name = root.value("name");
- AnnotationValue label = meta.value("label");
-
- if (name != null && label != null) {
- if (bannedDefinitions != null) {
- for (String bannedDefinition: bannedDefinitions) {
- if (AntPathMatcher.INSTANCE.match(bannedDefinition.replace('.', '/'), i.name().toString('/'))) {
- getLog().debug("Skipping definition: " + i.name().toString());
- return;
- }
- }
- }
+ if (meta == null || root == null) {
+ return;
+ }
+
+ AnnotationValue name = root.value("name");
+ AnnotationValue label = meta.value("label");
- Set<String> labels = Set.of(label.asString().split(",", -1));
- if (labels.contains("eip")) {
- String id = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, name.asString());
- if (ids.add(id)) {
- mb.beginControlFlow("case $S:", id);
- mb.addStatement("return new org.apache.camel.k.loader.yaml.parser.TypedProcessorStepParser($L.class)", i.name().toString());
- mb.endControlFlow();
- }
+ if (name == null || label == null) {
+ return;
+ }
+
+ if (bannedDefinitions != null) {
+ for (String bannedDefinition: bannedDefinitions) {
+ if (AntPathMatcher.INSTANCE.match(bannedDefinition.replace('.', '/'), i.name().toString('/'))) {
+ getLog().debug("Skipping definition: " + i.name().toString());
+ return;
}
}
}
+
+ Set<String> labels = Set.of(label.asString().split(",", -1));
+ if (labels.contains("eip")) {
+ String id = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, name.asString());
+ if (ids.add(id)) {
+ mb.beginControlFlow("case $S:", id);
+ mb.addStatement("return new org.apache.camel.k.loader.yaml.parser.TypedProcessorStepParser($L.class)", i.name().toString());
+ mb.endControlFlow();
+ }
+ }
}
);
diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlParserSupportClasses.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlParserSupportClasses.java
index 5a3570c..20afba1 100644
--- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlParserSupportClasses.java
+++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlParserSupportClasses.java
@@ -66,7 +66,7 @@ public class GenerateYamlParserSupportClasses extends GenerateYamlSupport {
.build()
.writeTo(Paths.get(output));
} catch (IOException e) {
- throw new MojoFailureException(e.getMessage());
+ throw new MojoFailureException(e.getMessage(), e);
}
}
diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlSchema.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlSchema.java
index dab3fcd..25857ad 100644
--- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlSchema.java
+++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlSchema.java
@@ -203,39 +203,43 @@ public class GenerateYamlSchema extends GenerateYamlSupport {
AnnotationInstance meta = i.classAnnotation(METADATA_ANNOTATION);
AnnotationInstance xmlRoot = i.classAnnotation(XML_ROOT_ELEMENT_ANNOTATION_CLASS);
- if (meta != null && xmlRoot != null) {
- AnnotationValue name = xmlRoot.value("name");
- AnnotationValue label = meta.value("label");
-
- if (name != null && label != null) {
- if (bannedDefinitions != null) {
- for (String bannedDefinition: bannedDefinitions) {
- if (AntPathMatcher.INSTANCE.match(bannedDefinition.replace('.', '/'), i.name().toString('/'))) {
- getLog().debug("Skipping definition: " + i.name().toString());
- return;
- }
- }
- }
-
- Set<String> labels = Set.of(label.asString().split(",", -1));
- if (labels.contains("eip")) {
- String stepId = StringHelper.camelCaseToDash(name.asString());
- if (!ids.add(stepId)) {
- return;
- }
+ if (meta == null || xmlRoot == null) {
+ return;
+ }
- processType(definitions.with(i.name().toString()), i);
+ AnnotationValue name = xmlRoot.value("name");
+ AnnotationValue label = meta.value("label");
- ObjectNode stepNode = definitions.with("step");
- stepNode.put("type", "object");
- stepNode.put("maxProperties", 1);
+ if (name == null || label == null) {
+ return;
+ }
- stepNode.with("properties")
- .putObject(stepId)
- .put("$ref", "#/items/definitions/" + i.name().toString());
+ if (bannedDefinitions != null) {
+ for (String bannedDefinition: bannedDefinitions) {
+ if (AntPathMatcher.INSTANCE.match(bannedDefinition.replace('.', '/'), i.name().toString('/'))) {
+ getLog().debug("Skipping definition: " + i.name().toString());
+ return;
}
}
}
+
+ Set<String> labels = Set.of(label.asString().split(",", -1));
+ if (labels.contains("eip")) {
+ String stepId = StringHelper.camelCaseToDash(name.asString());
+ if (!ids.add(stepId)) {
+ return;
+ }
+
+ processType(definitions.with(i.name().toString()), i);
+
+ ObjectNode stepNode = definitions.with("step");
+ stepNode.put("type", "object");
+ stepNode.put("maxProperties", 1);
+
+ stepNode.with("properties")
+ .putObject(stepId)
+ .put("$ref", "#/items/definitions/" + i.name().toString());
+ }
}
);
@@ -246,7 +250,7 @@ public class GenerateYamlSchema extends GenerateYamlSupport {
mapper.writerWithDefaultPrettyPrinter().writeValue(outputFile, root);
} catch (IOException e) {
- throw new MojoFailureException(e.getMessage());
+ throw new MojoFailureException(e.getMessage(), e);
}
}
@@ -449,9 +453,6 @@ public class GenerateYamlSchema extends GenerateYamlSupport {
}
protected void setJsonSchemaType(ObjectNode node, Type type) {
- String javaType = type.name().toString();
- ClassInfo typeClass = view.get().getClassByName(type.name());
-
if (type.kind() == Type.Kind.PARAMETERIZED_TYPE) {
ParameterizedType parameterized = type.asParameterizedType();
@@ -474,11 +475,13 @@ public class GenerateYamlSchema extends GenerateYamlSupport {
}
}
+ final ClassInfo typeClass = view.get().getClassByName(type.name());
if (typeClass != null && typeClass.classAnnotation(YAML_NODE_DEFINITION_ANNOTATION) != null) {
node.put("$ref", "#/items/definitions/" + type.name().toString());
return;
}
+ final String javaType = type.name().toString();
switch (javaType) {
/*
* <tr><th scope="row"> boolean <td style="text-align:center"> Z
@@ -541,7 +544,7 @@ public class GenerateYamlSchema extends GenerateYamlSupport {
throw new IllegalStateException("Unknown java_type: " + javaType + " on node: " + node);
}
} catch (ClassNotFoundException e) {
- throw new IllegalStateException("Unknown java_type: " + javaType + " on node: " + node);
+ throw new IllegalStateException("Unknown java_type: " + javaType + " on node: " + node, e);
}
}
}
diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogComponentDefinition.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogComponentDefinition.java
index 929f772..c554291 100644
--- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogComponentDefinition.java
+++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogComponentDefinition.java
@@ -64,7 +64,7 @@ public final class CatalogComponentDefinition extends CatalogDefinition {
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Container {
- private CatalogComponentDefinition delegate;
+ private final CatalogComponentDefinition delegate;
@JsonCreator
public Container(
diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogDataFormatDefinition.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogDataFormatDefinition.java
index 1ade47c..824e321 100644
--- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogDataFormatDefinition.java
+++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogDataFormatDefinition.java
@@ -43,7 +43,7 @@ public final class CatalogDataFormatDefinition extends CatalogDefinition {
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Container {
- private CatalogDataFormatDefinition delegate;
+ private final CatalogDataFormatDefinition delegate;
@JsonCreator
public Container(
diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogLanguageDefinition.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogLanguageDefinition.java
index d2d0f20..74d4459 100644
--- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogLanguageDefinition.java
+++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogLanguageDefinition.java
@@ -43,7 +43,7 @@ public final class CatalogLanguageDefinition extends CatalogDefinition {
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Container {
- private CatalogLanguageDefinition delegate;
+ private final CatalogLanguageDefinition delegate;
@JsonCreator
public Container(
diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor3x.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor3x.java
index 360908f..07d67be 100644
--- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor3x.java
+++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor3x.java
@@ -269,7 +269,7 @@ public class CatalogProcessor3x implements CatalogProcessor {
);
}
}
- private static void processComponents(org.apache.camel.catalog.CamelCatalog catalog, Map<String, CamelArtifact> artifacts) {
+ private static void processComponents(CamelCatalog catalog, Map<String, CamelArtifact> artifacts) {
for (String name : catalog.findComponentNames()) {
String json = catalog.componentJSonSchema(name);
CatalogComponentDefinition definition = CatalogSupport.unmarshallComponent(json);
@@ -292,7 +292,7 @@ public class CatalogProcessor3x implements CatalogProcessor {
}
}
- private static void processLanguages(org.apache.camel.catalog.CamelCatalog catalog, Map<String, CamelArtifact> artifacts) {
+ private static void processLanguages(CamelCatalog catalog, Map<String, CamelArtifact> artifacts) {
for (String name : catalog.findLanguageNames()) {
String json = catalog.languageJSonSchema(name);
CatalogLanguageDefinition definition = CatalogSupport.unmarshallLanguage(json);
@@ -307,7 +307,7 @@ public class CatalogProcessor3x implements CatalogProcessor {
}
}
- private static void processDataFormats(org.apache.camel.catalog.CamelCatalog catalog, Map<String, CamelArtifact> artifacts) {
+ private static void processDataFormats(CamelCatalog catalog, Map<String, CamelArtifact> artifacts) {
for (String name : catalog.findDataFormatNames()) {
String json = catalog.dataFormatJSonSchema(name);
CatalogDataFormatDefinition definition = CatalogSupport.unmarshallDataFormat(json);
diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/support/MavenSupport.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/support/MavenSupport.java
index 0cf167a..95cb827 100644
--- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/support/MavenSupport.java
+++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/support/MavenSupport.java
@@ -17,10 +17,13 @@
package org.apache.camel.k.tooling.maven.support;
import java.io.File;
+import java.io.InputStream;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
+import java.util.Properties;
+import java.util.function.Consumer;
import org.apache.maven.project.MavenProject;
@@ -44,4 +47,61 @@ public final class MavenSupport {
return IndexerSupport.class.getClassLoader();
}
}
+
+ public static String getVersion(Class<?> clazz, String path) {
+ String version = null;
+
+ // try to load from maven properties first
+ try (InputStream is = clazz.getResourceAsStream(path)) {
+ if (is != null) {
+ Properties p = new Properties();
+ p.load(is);
+ version = p.getProperty("version", "");
+ }
+ } catch (Exception ignored) {
+ }
+
+ // fallback to using Java API
+ if (version == null) {
+ Package aPackage = clazz.getPackage();
+ if (aPackage != null) {
+ version = getVersion(aPackage);
+ }
+ }
+
+ if (version == null) {
+ // we could not compute the version so use a blank
+ throw new IllegalStateException("Unable to determine runtime version");
+ }
+
+ return version;
+ }
+
+ public static String getVersion(Package pkg) {
+ String version = pkg.getImplementationVersion();
+ if (version == null) {
+ version = pkg.getSpecificationVersion();
+ }
+
+ return version;
+ }
+
+ public static void getVersion(Class<?> clazz, String path, Consumer<String> consumer) {
+ consumer.accept(
+ MavenSupport.getVersion(clazz, path)
+ );
+ }
+
+ public static void getVersion(Class<?> clazz, String groupId, String artifactId, Consumer<String> consumer) {
+ getVersion(
+ clazz,
+ String.format("/META-INF/maven/%s/%s/pom.properties", groupId, artifactId),
+ consumer);
+ }
+
+ public static String getVersion(Class<?> clazz, String groupId, String artifactId) {
+ return MavenSupport.getVersion(
+ clazz,
+ String.format("/META-INF/maven/%s/%s/pom.properties", groupId, artifactId));
+ }
}
diff --git a/tooling/pmd-ruleset.xml b/tooling/pmd-ruleset.xml
new file mode 100644
index 0000000..a20fd35
--- /dev/null
+++ b/tooling/pmd-ruleset.xml
@@ -0,0 +1,711 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<ruleset name="PMD-Rules" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
+ <description>PMD Rules that govern static code analysis for Camel K Runtime</description>
+ <rule ref="category/java/bestpractices.xml/ArrayIsStoredDirectly">
+ <priority>1</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/OneDeclarationPerLine">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/ControlStatementBraces">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/AvoidCatchingNPE">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/DoNotExtendJavaLangError">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/ClassNamingConventions">
+ <properties>
+ <property name="utilityClassPattern" value="[A-Z][a-zA-Z0-9]*" />
+ </properties>
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/design.xml/LogicInversion">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/BrokenNullCheck">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/UnnecessaryConstructor">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/DefaultLabelNotLastInSwitchStmt">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/MethodReturnsInternalArray">
+ <priority>1</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/UseCollectionIsEmpty">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/DoNotHardCodeSDCard">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/InsufficientStringBufferDeclaration">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/PositionLiteralsFirstInCaseInsensitiveComparisons">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/UseCorrectExceptionLogging">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/SuspiciousHashcodeMethodName">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/AvoidProtectedFieldInFinalClass">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/EmptyStatementNotInLoop">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/ExceptionAsFlowControl">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/UnconditionalIfStatement">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/FinalizeDoesNotCallSuperFinalize">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/SingletonClassReturningNewInstance">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/MethodWithSameNameAsEnclosingClass">
+ <priority>5</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/AvoidAssertAsIdentifier">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/AvoidUsingNativeCode">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/UseArraysAsList">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/DuplicateImports">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/SuspiciousOctalEscape">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/CheckResultSet">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/documentation.xml/CommentContent">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/ReplaceVectorWithList">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/design.xml/TooManyMethods">
+ <priority>5</priority>
+ <properties>
+ <property name="maxmethods" value="15" />
+ </properties>
+ </rule>
+ <rule ref="category/java/errorprone.xml/ConstructorCallsOverridableMethod">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/JUnit4SuitesShouldUseSuiteAnnotation">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/DoNotThrowExceptionInFinally">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/JUnitTestContainsTooManyAsserts">
+ <priority>5</priority>
+ <properties>
+ <property name="maximumAsserts" value="10" />
+ </properties>
+ </rule>
+ <rule ref="category/java/performance.xml/InefficientEmptyStringCheck">
+ <priority>5</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/AvoidProtectedMethodInFinalClassNotExtending">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/SingleMethodSingleton">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/FinalFieldCouldBeStatic">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/LooseCoupling">
+ <priority>5</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/UnnecessaryBooleanAssertion">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/SwitchDensity">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/UseStringBufferLength">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/JUnitUseExpected">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/BadComparison">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/CloneThrowsCloneNotSupportedException">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/UseEqualsToCompareStrings">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/MethodNamingConventions">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/EmptyWhileStmt">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/FieldDeclarationsShouldBeAtStartOfClass">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/EqualsNull">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/UnusedImports">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/PrematureDeclaration">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/PackageCase">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/LocalHomeNamingConvention">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/AbstractClassWithoutAbstractMethod">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/NoPackage">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/CallSuperFirst">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/MissingBreakInSwitch">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/AbstractClassWithoutAnyMethod">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/TooManyFields">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/UselessOverridingMethod">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/AddEmptyString">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/UselessStringValueOf">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/InvalidLogMessageFormat">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/FinalizeOverloaded">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/multithreading.xml/DontCallThreadRun">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/BooleanGetMethodName">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/UnnecessaryModifier">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/UseAssertTrueInsteadOfAssertEquals">
+ <priority>5</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/AvoidLosingExceptionInformation">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/SimplifiedTernary">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseBeforeAnnotation">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/AvoidPrintStackTrace">
+ <priority>1</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/TooFewBranchesForASwitchStatement">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/AvoidCatchingThrowable">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/EmptyIfStmt">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/EmptyInitializer">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/EmptyMethodInAbstractClassShouldBeAbstract">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/multithreading.xml/UseNotifyAllInsteadOfNotify">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/multithreading.xml/UnsynchronizedStaticFormatter">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/AvoidRethrowingException">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/LocalInterfaceSessionNamingConvention">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/UseIndexOfChar">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/UselessQualifiedThis">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/UnnecessaryCaseChange">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/ReplaceEnumerationWithIterator">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/UseArrayListInsteadOfVector">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/IntegerInstantiation">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/CloneMethodMustImplementCloneable">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/EmptyCatchBlock">
+ <priority>4</priority>
+ <properties>
+ <property name="allowCommentedBlocks" value="true" />
+ <property name="allowExceptionNameRegex" value="ignored" />
+ </properties>
+ </rule>
+ <rule ref="category/java/design.xml/AvoidThrowingNullPointerException">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/JumbledIncrementer">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/FinalizeShouldBeProtected">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/AvoidStringBufferField">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/UnusedPrivateField">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/ExcessivePublicCount">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/ShortClassName">
+ <priority>5</priority>
+ <properties>
+ <property name="minimum" value="3" />
+ </properties>
+ </rule>
+ <rule ref="category/java/codestyle.xml/LocalVariableNamingConventions">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/EmptyTryBlock">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/NonCaseLabelInSwitchStatement">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/SimplifyBooleanAssertion">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/CompareObjectsWithEquals">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/AssignmentToNonFinalStatic">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/AccessorClassGeneration">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/OptimizableToArrayCall">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/ByteInstantiation">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/design.xml/ExcessiveClassLength">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/TestClassWithoutTestCases">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/ConstantsInInterface">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/SimplifyStartsWith">
+ <priority>5</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/UnnecessaryReturn">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/CouplingBetweenObjects">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/BigIntegerInstantiation">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/SimpleDateFormatNeedsLocale">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/SwitchStmtsShouldHaveDefault">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/ExtendsObject">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/ProperLogger">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/UnusedFormalParameter">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/StaticEJBFieldShouldBeFinal">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/FormalParameterNamingConventions">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/FieldNamingConventions">
+ <priority>4</priority>
+ <properties>
+ <property name="enumConstantPattern" value="[A-Za-z_0-9]*" />
+ </properties>
+ </rule>
+ <rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/documentation.xml/UncommentedEmptyConstructor">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/FinalizeOnlyCallsSuperFinalize">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/UseLocaleWithCaseConversions">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/RedundantFieldInitializer">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/LongInstantiation">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/CloneMethodMustBePublic">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/RemoteSessionInterfaceNamingConvention">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/ConsecutiveLiteralAppends">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/MoreThanOneLogger">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/UnnecessaryLocalBeforeReturn">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/AvoidArrayLoops">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/UseAssertSameInsteadOfAssertTrue">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseAfterAnnotation">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/AvoidAccessibilityAlteration">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/UnusedPrivateMethod">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/UseVarargs">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/CheckSkipResult">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/JUnitTestsShouldIncludeAssert">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/StringBufferInstantiationWithChar">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/InefficientStringBuffering">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/ReplaceHashtableWithMap">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/multithreading.xml/AvoidThreadGroup">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/multithreading.xml/DoubleCheckedLocking">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/PositionLiteralsFirstInComparisons">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/PreserveStackTrace">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/EmptyFinalizer">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/ExcessiveParameterList">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/UseUtilityClass">
+ <priority>5</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/ProperCloneImplementation">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/CallSuperLast">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/SimplifyBooleanReturns">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/AvoidDollarSigns">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/EmptySwitchStatements">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/design.xml/AvoidThrowingNewInstanceOfSameException">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/UseObjectForClearerAPI">
+ <priority>5</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/AvoidEnumAsIdentifier">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/design.xml/SimplifyConditional">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/GenericsNaming">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/IdempotentOperations">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/StringToString">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/multithreading.xml/NonThreadSafeSingleton">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/EmptyFinallyBlock">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/CloneMethodReturnTypeMustMatchClassName">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/UseAssertNullInsteadOfAssertTrue">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/SuspiciousEqualsMethodName">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/MDBAndSessionBeanNamingConvention">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/DontImportSun">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/AssignmentInOperand">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/BooleanInstantiation">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/EmptyStatementBlock">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/DoNotCallSystemExit">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/DontImportJavaLang">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/AvoidUsingOctalValues">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/AvoidInstanceofChecksInCatchClause">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/JUnitStaticSuite">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/SystemPrintln">
+ <priority>1</priority>
+ </rule>
+ <rule ref="category/java/design.xml/CollapsibleIfStatements">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/SingularField">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/AvoidUsingShortType">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/AppendCharacterWithChar">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/AvoidCallingFinalize">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/GuardLogStatement">
+ <priority>5</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/JUnit4TestShouldUseTestAnnotation">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/DoNotCallGarbageCollectionExplicitly">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/UnnecessaryWrapperObjectCreation">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/ConsecutiveAppendsShouldReuse">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/multithreading.xml/AvoidSynchronizedAtMethodLevel">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/ImmutableField">
+ <priority>5</priority>
+ <properties>
+ <property name="violationSuppressXPath" value="//Annotation[./*/Name[@Image = 'Generated']]" />
+ </properties>
+ </rule>
+ <rule ref="category/java/errorprone.xml/MisplacedNullCheck">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/ReturnEmptyArrayRatherThanNull">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/ImportFromSamePackage">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/UselessOperationOnImmutable">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/StringInstantiation">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/UseAssertEqualsInsteadOfAssertTrue">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/performance.xml/ShortInstantiation">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/EmptySynchronizedBlock">
+ <priority>4</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/RemoteInterfaceNamingConvention">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/InstantiationToGetClass">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/MissingStaticMethodInNonInstantiatableClass">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/design.xml/SimplifyBooleanExpressions">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/codestyle.xml/TooManyStaticImports">
+ <priority>5</priority>
+ <properties>
+ <property name="maximumStaticImports" value="20" />
+ </properties>
+ </rule>
+ <rule ref="category/java/documentation.xml/UncommentedEmptyMethodBody">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/bestpractices.xml/UnusedLocalVariable">
+ <priority>3</priority>
+ </rule>
+ <rule ref="category/java/errorprone.xml/JUnitSpelling">
+ <priority>3</priority>
+ </rule>
+</ruleset>