Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nio failures on Windows #5392

Merged
merged 1 commit into from
Aug 18, 2023
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 @@ -17,11 +17,11 @@
package org.glassfish.jersey;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.AccessController;
import java.security.KeyManagementException;
import java.security.KeyStore;
Expand Down Expand Up @@ -636,7 +636,7 @@ public SSLContext createSSLContext() {
if (keyStoreBytes != null) {
keyStoreInputStream = new ByteArrayInputStream(keyStoreBytes);
} else if (!keyStoreFile.equals("NONE")) {
keyStoreInputStream = Files.newInputStream(Paths.get(keyStoreFile));
keyStoreInputStream = Files.newInputStream(new File(keyStoreFile).toPath());
}
_keyStore.load(keyStoreInputStream, keyStorePass);
} finally {
Expand Down Expand Up @@ -711,7 +711,7 @@ public SSLContext createSSLContext() {
if (trustStoreBytes != null) {
trustStoreInputStream = new ByteArrayInputStream(trustStoreBytes);
} else if (!trustStoreFile.equals("NONE")) {
trustStoreInputStream = Files.newInputStream(Paths.get(trustStoreFile));
trustStoreInputStream = Files.newInputStream(new File(trustStoreFile).toPath());
}
_trustStore.load(trustStoreInputStream, trustStorePass);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

package org.glassfish.jersey.server.internal.scanning;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
Expand Down Expand Up @@ -155,7 +155,7 @@ private InputStream getInputStream(final String jarUrlString) throws IOException
return new URL(jarUrlString).openStream();
} catch (final MalformedURLException e) {
return Files.newInputStream(
Paths.get(UriComponent.decode(jarUrlString, UriComponent.Type.PATH)));
new File(UriComponent.decode(jarUrlString, UriComponent.Type.PATH)).toPath());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
Expand Down Expand Up @@ -90,7 +89,7 @@ public static File createJarFile(final String name, final Suffix s, final String
jos.putNextEntry(e);

final InputStream f = new BufferedInputStream(
Files.newInputStream(Paths.get(base + entry.getKey())));
Files.newInputStream(new File(base, entry.getKey()).toPath()));
final byte[] buf = new byte[1024];
int read = 1024;
while ((read = f.read(buf, 0, read)) != -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

package org.glassfish.jersey.server.mvc.spi;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -182,7 +182,7 @@ private T resolve(final String name) {
// File-system path.
if (reader == null) {
try {
reader = new InputStreamReader(Files.newInputStream(Paths.get(template)), encoding);
reader = new InputStreamReader(Files.newInputStream(new File(template).toPath()), encoding);
} catch (final IOException ioe) {
// NOOP.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.OutputStream;
import java.io.StringWriter;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -97,7 +97,7 @@ static boolean createOutputFile(String filePath, DocProcessor docProcessor, Reso
Class<?>[] classes = getJAXBContextClasses(result, docProcessor);
LOG.info("cdataElements " + Arrays.asList(cdataElements));
LOG.info("classes " + Arrays.asList(classes));
try (OutputStream out = new BufferedOutputStream(Files.newOutputStream(Paths.get(filePath)))) {
try (OutputStream out = new BufferedOutputStream(Files.newOutputStream(new File(filePath).toPath()))) {
JAXBContext c = JAXBContext.newInstance(classes);
Marshaller m = c.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
import org.apache.maven.project.MavenProject;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
Expand Down Expand Up @@ -315,7 +315,7 @@ public void setLog(org.apache.maven.plugin.logging.Log log) {
}

public String readFile(String fileName) throws IOException {
BufferedReader reader = Files.newBufferedReader(Paths.get(fileName));
BufferedReader reader = Files.newBufferedReader(new File(fileName).toPath());
String s;
StringBuilder sb = new StringBuilder();
while ((s = reader.readLine()) != null) {
Expand Down