Skip to content

Commit 64226fe

Browse files
committed
Port log4j-kubernetes changes from 2.x
We port mostly aesthetical changes from `2.x`. Part of #2016.
1 parent 6eed880 commit 64226fe

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

log4j-kubernetes/pom.xml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,19 @@
2323
<version>${revision}</version>
2424
<relativePath>../log4j-parent</relativePath>
2525
</parent>
26-
2726
<artifactId>log4j-kubernetes</artifactId>
2827
<packaging>jar</packaging>
2928
<name>Apache Log4j Kubernetes Library</name>
3029
<description>Apache Log4j Kubernetes Support</description>
3130
<properties>
32-
<log4jParentDir>${basedir}/..</log4jParentDir>
3331

3432
<!--
3533
~ OSGi and JPMS options
3634
-->
3735
<bnd-extra-module-options>
38-
<!-- Standardize names -->
39-
kubernetes.client;substitute="kubernetes-client",
40-
kubernetes.model.core;substitute="kubernetes-model-core
36+
<!-- Filebased module names: MUST be static -->
37+
kubernetes.client;substitute="kubernetes-client";transitive=false;static=true,
38+
kubernetes.model.core;substitute="kubernetes-model-core";transitive=false;static=true
4139
</bnd-extra-module-options>
4240
<Fragment-Host>org.apache.logging.log4j.core</Fragment-Host>
4341
</properties>
@@ -55,11 +53,6 @@
5553
<groupId>io.fabric8</groupId>
5654
<artifactId>kubernetes-client</artifactId>
5755
</dependency>
58-
<dependency>
59-
<groupId>org.hamcrest</groupId>
60-
<artifactId>hamcrest</artifactId>
61-
<scope>test</scope>
62-
</dependency>
6356
<dependency>
6457
<groupId>org.junit.jupiter</groupId>
6558
<artifactId>junit-jupiter-engine</artifactId>

log4j-kubernetes/src/main/java/org/apache/logging/log4j/kubernetes/ContainerUtil.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ public static String getContainerId() {
5656
.orElse(null);
5757
LOGGER.debug("Found container id {}", id);
5858
return id;
59-
} else {
60-
LOGGER.warn("Unable to access container information");
6159
}
60+
LOGGER.warn("Unable to access container information");
6261
} catch (IOException ioe) {
6362
LOGGER.warn("Error obtaining container id: {}", ioe.getMessage());
6463
}

log4j-kubernetes/src/main/java/org/apache/logging/log4j/kubernetes/KubernetesLookup.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import io.fabric8.kubernetes.api.model.Container;
2020
import io.fabric8.kubernetes.api.model.ContainerStatus;
21+
import io.fabric8.kubernetes.api.model.Namespace;
2122
import io.fabric8.kubernetes.api.model.Pod;
2223
import io.fabric8.kubernetes.client.Config;
2324
import io.fabric8.kubernetes.client.KubernetesClient;
@@ -57,7 +58,7 @@ public class KubernetesLookup extends AbstractLookup {
5758
LoaderUtil.isClassAvailable("org.apache.logging.log4j.spring.cloud.config.client.SpringEnvironmentHolder")
5859
|| LoaderUtil.isClassAvailable("org.apache.logging.log4j.spring.boot.SpringEnvironmentHolder");
5960
private Pod pod;
60-
private io.fabric8.kubernetes.api.model.Namespace namespace;
61+
private Namespace namespace;
6162
private URL masterUrl;
6263

6364
public KubernetesLookup() {
@@ -67,7 +68,7 @@ public KubernetesLookup() {
6768
initialize();
6869
}
6970

70-
KubernetesLookup(Pod pod, io.fabric8.kubernetes.api.model.Namespace namespace, URL masterUrl) {
71+
KubernetesLookup(Pod pod, Namespace namespace, URL masterUrl) {
7172
this.pod = pod;
7273
this.namespace = namespace;
7374
this.masterUrl = masterUrl;

log4j-kubernetes/src/test/java/org/apache/logging/log4j/kubernetes/KubernetesLookupTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ public void testLocal() throws Exception {
6060
assertEquals("Incorrect pod name", "sampleapp-584f99476d-mnrp4", lookup.lookup("podName"));
6161
} finally {
6262
lookup.clearInfo();
63-
;
6463
}
6564
}
6665

0 commit comments

Comments
 (0)