Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Paths;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
Expand Down Expand Up @@ -217,8 +218,8 @@ public X509Certificate[] getAcceptedIssuers() {

static {
String javaHome = System.getProperty("java.home");
String defaultTruststorePath = javaHome + File.separator + "lib" + File.separator + "security" + File.separator + "cacerts";
DEFAULT_TRUSTSTORE_PATH = new File(defaultTruststorePath);
var defaultTruststorePath = Paths.get(javaHome, "lib", "security", "cacerts");
DEFAULT_TRUSTSTORE_PATH = defaultTruststorePath.toFile();
}

public static FileInputStream getDefaultTruststoreStreamIfPossible() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.jivesoftware.smackx.formtypes;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -105,26 +104,23 @@ private static void loadFormFieldRegistryEntry(InputStream inputStream, String s
}
}
}

private static void loadFormFieldRegistryEntries() throws IOException, IllegalStateException, XmlPullParserException, URISyntaxException {
var url = XDataManager.class.getProtectionDomain().getCodeSource().getLocation();
if (url == null) throw new IllegalStateException();

if (url.getProtocol().equals("file") && !url.getPath().endsWith(".jar")) {
var path = Paths.get(url.toURI());
if (!Files.isDirectory(path)) throw new IllegalStateException("Code source location " + url + " is not a directory");
var prefix = path.toString() + File.separator + "org.igniterealtime.smack" + File.separator + "xdata"
+ File.separator + "form-registry" + File.separator;
var prefix = Paths.get(path.toString(), "org.igniterealtime.smack", "xdata", "form-registry").toString();

try (var walk = Files.walk(path)) {
var files = walk.filter(Files::isRegularFile)
.filter(f -> f.toString().startsWith(prefix))
.collect(Collectors.toList());
for (var file : files) {
var inputStream = Files.newInputStream(file);
try {
try (var inputStream = Files.newInputStream(file)) {
Comment thread
stokito marked this conversation as resolved.
loadFormFieldRegistryEntry(inputStream, file.toString());
} finally {
inputStream.close();
}
}
}
Expand All @@ -138,11 +134,8 @@ private static void loadFormFieldRegistryEntries() throws IOException, IllegalSt
.filter(e -> e.getName().startsWith("org.igniterealtime.smack/xdata/form-registry/"))
.collect(Collectors.toList());
for (var file : files) {
var inputStream = jar.getInputStream(file);
try {
try (var inputStream = jar.getInputStream(file)) {
loadFormFieldRegistryEntry(inputStream, file.toString());
} finally {
inputStream.close();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
*/
package org.igniterealtime.smack.inttest.debugger;

import java.io.File;
import java.io.IOException;
import java.io.Writer;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.logging.Level;
Expand Down Expand Up @@ -61,12 +61,11 @@ public StandardSinttestDebugger(ZonedDateTime restRunStart, String testRunId, St
// We don't want to fill up the memory.
tmpdir = "/var/tmp";
}
String basePath = tmpdir
+ File.separator
+ "sinttest-" + System.getProperty("user.name")
+ File.separator
+ DATE_TIME_FORMATTER.format(restRunStart) + "-" + testRunId
;
Path basePath = Paths.get(
tmpdir,
"sinttest-" + System.getProperty("user.name"),
DATE_TIME_FORMATTER.format(restRunStart) + "-" + testRunId
);
boolean console = true;

if (options != null) {
Expand Down Expand Up @@ -98,7 +97,7 @@ public StandardSinttestDebugger(ZonedDateTime restRunStart, String testRunId, St
basePath = null;
break;
default:
basePath = value;
basePath = Path.of(value);
break;
}
break;
Expand All @@ -109,7 +108,7 @@ public StandardSinttestDebugger(ZonedDateTime restRunStart, String testRunId, St
}

if (basePath != null) {
this.basePath = Path.of(basePath);
this.basePath = basePath;
Path completeLogFile = this.basePath.resolve("completeLog");
Path outsideTestLogFile = this.basePath.resolve("outsideTestLog");
Path testsFile = this.basePath.resolve("tests");
Expand Down