Skip to content

Commit

Permalink
Modernization: Using NIO2 instead of IO
Browse files Browse the repository at this point in the history
  • Loading branch information
mkarg committed Dec 22, 2024
1 parent cdbc48b commit 0a5d834
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
18 changes: 9 additions & 9 deletions jaxrs-api/src/main/java/jakarta/ws/rs/client/FactoryFinder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -16,9 +16,10 @@

package jakarta.ws.rs.client;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Properties;
Expand Down Expand Up @@ -123,15 +124,14 @@ static <T> Object find(final String factoryId, final Class<T> service) throws Cl
}

// try to read from $java.home/lib/jaxrs.properties
FileInputStream inputStream = null;
String configFile = null;
InputStream inputStream = null;
Path configFile = null;
try {
String javah = System.getProperty("java.home");
configFile = javah + File.separator + "lib" + File.separator + "jaxrs.properties";
File f = new File(configFile);
if (f.exists()) {
configFile = Path.of(javah, "lib", "jaxrs.properties");
if (Files.exists(configFile)) {
Properties props = new Properties();
inputStream = new FileInputStream(f);
inputStream = Files.newInputStream(configFile);
props.load(inputStream);
String factoryClassName = props.getProperty(factoryId);
return newInstance(factoryClassName, classLoader);
Expand Down
18 changes: 9 additions & 9 deletions jaxrs-api/src/main/java/jakarta/ws/rs/ext/FactoryFinder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -16,9 +16,10 @@

package jakarta.ws.rs.ext;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Properties;
Expand Down Expand Up @@ -123,15 +124,14 @@ static <T> Object find(final String factoryId, final Class<T> service) throws Cl
}

// try to read from $java.home/lib/jaxrs.properties
FileInputStream inputStream = null;
String configFile = null;
InputStream inputStream = null;
Path configFile = null;
try {
String javah = System.getProperty("java.home");
configFile = javah + File.separator + "lib" + File.separator + "jaxrs.properties";
File f = new File(configFile);
if (f.exists()) {
configFile = Path.of(javah, "lib", "jaxrs.properties");
if (Files.exists(configFile)) {
Properties props = new Properties();
inputStream = new FileInputStream(f);
inputStream = Files.newInputStream(configFile);
props.load(inputStream);
String factoryClassName = props.getProperty(factoryId);
return newInstance(factoryClassName, classLoader);
Expand Down
18 changes: 9 additions & 9 deletions jaxrs-api/src/main/java/jakarta/ws/rs/sse/FactoryFinder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -16,9 +16,10 @@

package jakarta.ws.rs.sse;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Properties;
Expand Down Expand Up @@ -123,15 +124,14 @@ static <T> Object find(final String factoryId, final Class<T> service) throws Cl
}

// try to read from $java.home/lib/jaxrs.properties
FileInputStream inputStream = null;
String configFile = null;
Path configFile = null;
InputStream inputStream = null;
try {
String javah = System.getProperty("java.home");
configFile = javah + File.separator + "lib" + File.separator + "jaxrs.properties";
File f = new File(configFile);
if (f.exists()) {
configFile = Path.of(javah, "lib", "jaxrs.properties");
if (Files.exists(configFile)) {
Properties props = new Properties();
inputStream = new FileInputStream(f);
inputStream = Files.newInputStream(configFile);
props.load(inputStream);
String factoryClassName = props.getProperty(factoryId);
return newInstance(factoryClassName, classLoader);
Expand Down

0 comments on commit 0a5d834

Please sign in to comment.