diff --git a/dd-java-agent/src/test/java/datadog/trace/agent/test/IntegrationTestUtils.java b/dd-java-agent/src/test/java/datadog/trace/agent/test/IntegrationTestUtils.java index e95ff4af6e1..07703a35bce 100644 --- a/dd-java-agent/src/test/java/datadog/trace/agent/test/IntegrationTestUtils.java +++ b/dd-java-agent/src/test/java/datadog/trace/agent/test/IntegrationTestUtils.java @@ -6,7 +6,6 @@ import datadog.trace.bootstrap.BootstrapProxy; import java.io.BufferedReader; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -15,6 +14,7 @@ import java.lang.management.RuntimeMXBean; import java.lang.reflect.Field; import java.net.URL; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -65,26 +65,26 @@ public static URL createJarWithClasses(final Class... classes) throws IOExcep * *

The jar file will be removed when the jvm exits. * - * @param mainClassname The name of the class to use for Main-Class and Premain-Class. May be null + * @param mainClassName The name of the class to use for Main-Class and Premain-Class. May be null * @param classes classes to package into the jar. * @return the location of the newly created jar. * @throws IOException */ - public static File createJarFileWithClasses(final String mainClassname, final Class... classes) + public static File createJarFileWithClasses(final String mainClassName, final Class... classes) throws IOException { - final File tmpJar = File.createTempFile(UUID.randomUUID().toString() + "-", ".jar"); + final File tmpJar = File.createTempFile(UUID.randomUUID() + "-", ".jar"); tmpJar.deleteOnExit(); final Manifest manifest = new Manifest(); - if (mainClassname != null) { + if (mainClassName != null) { final Attributes mainAttributes = manifest.getMainAttributes(); mainAttributes.put(Attributes.Name.MANIFEST_VERSION, "1.0"); - mainAttributes.put(Attributes.Name.MAIN_CLASS, mainClassname); - mainAttributes.put(new Attributes.Name("Premain-Class"), mainClassname); + mainAttributes.put(Attributes.Name.MAIN_CLASS, mainClassName); + mainAttributes.put(new Attributes.Name("Premain-Class"), mainClassName); } try (final JarOutputStream target = - new JarOutputStream(new FileOutputStream(tmpJar), manifest)) { + new JarOutputStream(Files.newOutputStream(tmpJar.toPath()), manifest)) { for (final Class clazz : classes) { addToJar(clazz, target); } @@ -93,10 +93,10 @@ public static File createJarFileWithClasses(final String mainClassname, final Cl return tmpJar; } - public static URL createJarWithClasses(final String mainClassname, final Class... classes) + public static URL createJarWithClasses(final String mainClassName, final Class... classes) throws IOException { - return createJarFileWithClasses(mainClassname, classes).toURI().toURL(); + return createJarFileWithClasses(mainClassName, classes).toURI().toURL(); } private static void addToJar(final Class clazz, final JarOutputStream jarOutputStream) @@ -312,7 +312,7 @@ private StreamGobbler(final InputStream stream, final String type, final PrintSt public void run() { try { final BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); - String line = null; + String line; while ((line = reader.readLine()) != null) { if (null != out) { out.println(type + "> " + line); diff --git a/dd-java-agent/src/test/java/jvmbootstraptest/CustomSecurityManager.java b/dd-java-agent/src/test/java/jvmbootstraptest/CustomSecurityManager.java index 1cd91e5047b..591fb6283bd 100644 --- a/dd-java-agent/src/test/java/jvmbootstraptest/CustomSecurityManager.java +++ b/dd-java-agent/src/test/java/jvmbootstraptest/CustomSecurityManager.java @@ -358,7 +358,8 @@ protected final boolean defaultCheckFileReadPermission( || isEtcFile(filePath) || isTimeZoneDb(filePath) || isNetProperties(filePath) - || isIbmFile(filePath); + || isIbmFile(filePath) + || isOracleFile(filePath); } protected boolean checkFileWritePermission(FilePermission perm, Object ctx, String filePath) { @@ -391,6 +392,10 @@ protected static final boolean isIbmFile(String filePath) { return filePath.endsWith("/tmp/.com_ibm_tools_attach"); } + protected static final boolean isOracleFile(String filePath) { + return filePath.contains("/oracle8"); + } + protected static final boolean isLibraryFile(String filePath) { return filePath.endsWith(".dylib") || filePath.endsWith(".so") || filePath.endsWith(".dll"); } diff --git a/dd-java-agent/src/test/java/jvmbootstraptest/InitializationTelemetryCheck.java b/dd-java-agent/src/test/java/jvmbootstraptest/InitializationTelemetryCheck.java index 0db64149b3d..23d1f1bec2a 100644 --- a/dd-java-agent/src/test/java/jvmbootstraptest/InitializationTelemetryCheck.java +++ b/dd-java-agent/src/test/java/jvmbootstraptest/InitializationTelemetryCheck.java @@ -136,7 +136,7 @@ static final void write(File file, String... lines) throws IOException { Files.write(file.toPath(), Arrays.asList(lines)); } - static final String read(File file) throws IOException { + static final String read(File file) { try { return new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8); } catch (IOException e) {