Skip to content

Commit

Permalink
Misc fixes (warning for log4j2, print java version) (#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
basilisk487 authored May 20, 2020
1 parent 17663a4 commit 82d315a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/etc/init.d/wavefront-proxy
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ if [[ -z "$PROXY_JAVA_HOME" && ! -r $proxy_jre_dir/bin/java ]]; then
JAVA_HOME=$($(dirname $(dirname $(readlink -f $(which javac)))))
echo "Using Java runtime $JAVA_VERSION detected in $JAVA_HOME" >&2
else
echo "Java runtime [1.8; 12) not found - trying to download and install" >&2
echo "Found Java runtime $JAVA_VERSION, needs 8, 9, 10 or 11 to run - trying to download and install" >&2
download_jre
fi
else
Expand Down
3 changes: 3 additions & 0 deletions proxy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.wavefront.agent.PushAgent</mainClass>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</transformer>
</transformers>
<filters>
Expand Down
13 changes: 9 additions & 4 deletions proxy/src/main/java/com/wavefront/agent/AbstractAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import static com.wavefront.agent.ProxyUtil.getOrCreateProxyId;
import static com.wavefront.common.Utils.csvToList;
import static com.wavefront.common.Utils.getBuildVersion;
import static com.wavefront.common.Utils.getJavaVersion;
import static java.util.Collections.EMPTY_LIST;
import static org.apache.commons.lang3.StringUtils.isEmpty;

Expand Down Expand Up @@ -180,9 +181,12 @@ protected LogsIngestionConfig loadLogsIngestionConfig() {
}

private void postProcessConfig() {
System.setProperty("org.apache.commons.logging.Log",
"org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http", "warn");
// disable useless info messages when httpClient has to retry a request due to a stale
// connection. the alternative is to always validate connections before reuse, but since
// it happens fairly infrequently, and connection re-validation performance penalty is
// incurred every time, suppressing that message seems to be a more reasonable approach.
org.apache.log4j.Logger.getLogger("org.apache.http.impl.execchain.RetryExec").
setLevel(org.apache.log4j.Level.WARN);

if (StringUtils.isBlank(proxyConfig.getHostname().trim())) {
logger.severe("hostname cannot be blank! Please correct your configuration settings.");
Expand All @@ -193,7 +197,8 @@ private void postProcessConfig() {
@VisibleForTesting
void parseArguments(String[] args) {
// read build information and print version.
String versionStr = "Wavefront Proxy version " + getBuildVersion();
String versionStr = "Wavefront Proxy version " + getBuildVersion() +
", runtime: " + getJavaVersion();
try {
if (!proxyConfig.parseArguments(args, this.getClass().getCanonicalName())) {
System.exit(0);
Expand Down
11 changes: 11 additions & 0 deletions proxy/src/main/java/com/wavefront/common/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ public static String getBuildVersion() {
}
}

/**
* Returns current java runtime version information (name/vendor/version) as a string.
*
* @return java runtime version as string
*/
public static String getJavaVersion() {
return System.getProperty("java.runtime.name", "(unknown runtime)") + " (" +
System.getProperty("java.vendor", "") + ") " +
System.getProperty("java.version", "(unknown version)");
}

/**
* Makes a best-effort attempt to resolve the hostname for the local host.
*
Expand Down

0 comments on commit 82d315a

Please sign in to comment.