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

Remove usages of deprecated ReaderFactory class #339

Merged
merged 1 commit into from
Nov 18, 2024
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 @@ -29,6 +29,9 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -82,7 +85,6 @@
import org.codehaus.plexus.components.interactivity.InputHandler;
import org.codehaus.plexus.languages.java.version.JavaVersion;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;

/**
Expand Down Expand Up @@ -532,10 +534,10 @@ private void init() {
// encoding
if (encoding == null || encoding.isEmpty()) {
if (getLog().isWarnEnabled()) {
getLog().warn("File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
getLog().warn("File encoding has not been set, using platform encoding " + Charset.defaultCharset()
+ ", i.e. build is platform dependent!");
}
encoding = ReaderFactory.FILE_ENCODING;
encoding = Charset.defaultCharset().name();
}

// level
Expand Down Expand Up @@ -689,13 +691,13 @@ private void parseClirrTextOutputFile(File clirrTextOutputFile) throws IOExcepti
clirrNewClasses = new LinkedList<>();
clirrNewMethods = new LinkedHashMap<>();

try (BufferedReader reader = new BufferedReader(ReaderFactory.newReader(clirrTextOutputFile, "UTF-8"))) {
try (BufferedReader reader = Files.newBufferedReader(clirrTextOutputFile.toPath(), StandardCharsets.UTF_8)) {

for (String line = reader.readLine(); line != null; line = reader.readLine()) {
String[] split = StringUtils.split(line, ":");
if (split.length != 4) {
if (getLog().isDebugEnabled()) {
getLog().debug("Unable to parse the clirr line: " + line);
getLog().debug("Unable to parse the Clirr line: " + line);
}
continue;
}
Expand Down Expand Up @@ -2098,26 +2100,6 @@ private void appendDefaultSinceTag(final StringBuilder sb, final String indent)
sb.append(EOL);
}

/**
* @param sb not null
* @param indent not null
* @param separatorAdded
* @return true if separator has been added.
*/
private boolean appendDefaultVersionTag(final StringBuilder sb, final String indent, boolean separatorAdded) {
if (!fixTag(VERSION_TAG) || StringUtils.isEmpty(defaultVersion)) {
return separatorAdded;
}

if (!separatorAdded) {
appendSeparator(sb, indent);
separatorAdded = true;
}

appendDefaultVersionTag(sb, indent);
return separatorAdded;
}

/**
* @param sb not null
* @param indent not null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.WriterFactory;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
Expand Down Expand Up @@ -1836,14 +1835,16 @@ private String getCharset() {
* @return the docencoding attribute or <code>UTF-8</code> if <code>null</code>.
*/
private String getDocencoding() {
return (docencoding == null || docencoding.isEmpty()) ? ReaderFactory.UTF_8 : docencoding;
return (docencoding == null || docencoding.isEmpty()) ? StandardCharsets.UTF_8.name() : docencoding;
}

/**
* @return the encoding attribute or the value of <code>file.encoding</code> system property if <code>null</code>.
*/
private String getEncoding() {
return (encoding == null || encoding.isEmpty()) ? ReaderFactory.FILE_ENCODING : encoding;
return (encoding == null || encoding.isEmpty())
? Charset.defaultCharset().name()
: encoding;
}

@Override
Expand Down Expand Up @@ -4596,7 +4597,7 @@ private void addJavadocOptions(

if (encoding == null || encoding.isEmpty()) {
getLog().warn("Source files encoding has not been set, using platform encoding "
+ ReaderFactory.FILE_ENCODING + ", i.e. build is platform dependent!");
+ Charset.defaultCharset().name() + ", i.e. build is platform dependent!");
}
addArgIfNotEmpty(arguments, "-encoding", JavadocUtil.quotedArgument(getEncoding()));

Expand Down