From: Waldemar Kozaczuk <[email protected]> Committer: Waldemar Kozaczuk <[email protected]> Branch: master
java: include the conf/ subdirectory of openjdk 9 and above This patch modifies the makefile of openjdk9_1x-from-host module to include the conf/ subdirectory which among many things contains key configuration files like java.security that drives random generation logic and affects creating temporary files. If those files are missing creating temporary files is very slow as described in the issue #1165. Besides addressing the isssue #1165 this patch adds new Java test to verify that the temporary files can be created correctly on JDK 9 and above. It also makes both - 8 and 9+ - JDK modules include libnss3.so which is necessary with the version of JDK on Fedora. Fixes #1165 Signed-off-by: Waldemar Kozaczuk <[email protected]> --- diff --git a/modules/java-tests/tests-for-java9_1x/pom.xml b/modules/java-tests/tests-for-java9_1x/pom.xml --- a/modules/java-tests/tests-for-java9_1x/pom.xml +++ b/modules/java-tests/tests-for-java9_1x/pom.xml @@ -15,6 +15,16 @@ <artifactId>junit</artifactId> <version>4.13.1</version> </dependency> + <dependency> + <groupId>org.easytesting</groupId> + <artifactId>fest-assert</artifactId> + <version>1.4</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.7</version> + </dependency> </dependencies> <build> @@ -55,8 +65,8 @@ <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> - <source>1.7</source> - <target>1.7</target> + <source>1.8</source> + <target>1.8</target> </configuration> </plugin> </plugins> diff --git a/modules/java-tests/tests-for-java9_1x/src/main/java/io/osv/LoggingTest.java b/modules/java-tests/tests-for-java9_1x/src/main/java/io/osv/LoggingTest.java --- a/modules/java-tests/tests-for-java9_1x/src/main/java/io/osv/LoggingTest.java +++ b/modules/java-tests/tests-for-java9_1x/src/main/java/io/osv/LoggingTest.java @@ -0,0 +1 @@ +../../../../../../tests/src/main/java/io/osv/LoggingTest.java \ No newline at end of file diff --git a/modules/java-tests/tests/src/main/java/io/osv/BasicTests.java b/modules/java-tests/tests/src/main/java/io/osv/BasicTests.java --- a/modules/java-tests/tests/src/main/java/io/osv/BasicTests.java +++ b/modules/java-tests/tests/src/main/java/io/osv/BasicTests.java @@ -12,7 +12,8 @@ @RunWith(Suite.class) @Suite.SuiteClasses({ - BasicTest.class + BasicTest.class, + LoggingTest.class }) public class BasicTests { } diff --git a/modules/java-tests/tests/src/main/java/io/osv/LoggingTest.java b/modules/java-tests/tests/src/main/java/io/osv/LoggingTest.java --- a/modules/java-tests/tests/src/main/java/io/osv/LoggingTest.java +++ b/modules/java-tests/tests/src/main/java/io/osv/LoggingTest.java @@ -0,0 +1,65 @@ +package io.osv; + +import org.junit.Test; + +import java.io.File; +import java.io.IOException; +import java.util.List; + +import java.util.logging.FileHandler; +import java.util.logging.SimpleFormatter; +import java.util.logging.Logger; +import static java.util.logging.Level.INFO; + +import static org.apache.commons.io.FileUtils.forceDeleteOnExit; +import static org.apache.commons.io.FileUtils.readLines; +import static org.fest.assertions.Assertions.assertThat; + +/* + * Copyright (C) 2021 Waldemar Kozaczuk + * + * This work is open source software, licensed under the terms of the + * BSD license as described in the LICENSE file in the top-level directory. + */ +public class LoggingTest { + private static final String LOGGER_NAME = "test-logger"; + + @Test + public void testLogger() throws Throwable { + File log = newTemporaryFile(); + + Thread thread = new Thread(() -> { + try { + FileHandler handler = new FileHandler(log.getAbsolutePath()); + handler.setFormatter(new SimpleFormatter()); + + Logger logger = Logger.getLogger(LOGGER_NAME); + logger.addHandler(handler); + logger.setLevel(INFO); + + logger.info("ctx"); + logger.warning("ctx"); + } catch (IOException ex) { + System.err.println("Error: " + ex.toString()); + assertThat(true).isFalse(); + } + }); + thread.start(); + thread.join(); + + final List<String> logLines = readLines(log); + for (String line : logLines) + System.out.println(line); + + assertThat(logLines) + .hasSize(4) + .contains("INFO: ctx") + .contains("WARNING: ctx"); + } + + private File newTemporaryFile() throws IOException { + File file = File.createTempFile("test", null); + forceDeleteOnExit(file); + return file; + } +} diff --git a/modules/openjdk8-from-host/Makefile b/modules/openjdk8-from-host/Makefile --- a/modules/openjdk8-from-host/Makefile +++ b/modules/openjdk8-from-host/Makefile @@ -15,6 +15,7 @@ libsunec_path = $(shell find $(java_jdk_path) -name libsunec.so) module: $(call very-quiet, $(SRC)/scripts/manifest_from_host.sh $(libsunec_path) > usr.manifest) $(call very-quiet, $(SRC)/scripts/manifest_from_host.sh -li libfreeblpriv3.so >> usr.manifest) + $(call very-quiet, $(SRC)/scripts/manifest_from_host.sh -li libnss3.so >> usr.manifest) clean: rm -f usr.manifest diff --git a/modules/openjdk9_1x-from-host/Makefile b/modules/openjdk9_1x-from-host/Makefile --- a/modules/openjdk9_1x-from-host/Makefile +++ b/modules/openjdk9_1x-from-host/Makefile @@ -22,7 +22,9 @@ module: esac $(call very-quiet, $(SRC)/scripts/manifest_from_host.sh $(libsunec_path) > usr.manifest) $(call very-quiet, $(SRC)/scripts/manifest_from_host.sh -li libfreeblpriv3.so >> usr.manifest) + $(call very-quiet, $(SRC)/scripts/manifest_from_host.sh -li libnss3.so >> usr.manifest) $(call very-quiet, echo "/usr/lib/jvm/java/lib/security/default.policy: $(java_jdk_path)/lib/security/default.policy" >> usr.manifest) + $(call very-quiet, echo "/usr/lib/jvm/java/conf/**: $(java_jdk_path)/conf/**" >> usr.manifest) clean: rm -f usr.manifest -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/000000000000e5ada605d41a71aa%40google.com.
