Skip to content

Commit

Permalink
Remove deprecated API calls in commons-io and commons-lang.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Jan 18, 2024
1 parent 6ca4852 commit 5f6136f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public String detectPackageName(final String fileName, final Charset charset) {

@VisibleForTesting
String detectPackageName(final InputStream stream, final Charset charset) throws IOException {
try (BufferedReader buffer = new BufferedReader(new InputStreamReader(new BOMInputStream(stream), charset))) {
try (BufferedReader buffer = new BufferedReader(new InputStreamReader(BOMInputStream.builder().setInputStream(stream).get(), charset))) {
return detectPackageName(buffer.lines());
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/edu/hm/hafner/analysis/FileReaderFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public Reader create() {
if (isCharsetUndetected) {
charset = detectCharset(Files.newInputStream(file));
}
InputStream inputStream = Files.newInputStream(file);

return new InputStreamReader(new BOMInputStream(inputStream), getCharset());
var inputStream = Files.newInputStream(file);
var bomInputStream = BOMInputStream.builder().setInputStream(inputStream).get();
return new InputStreamReader(bomInputStream, getCharset());
}
catch (FileNotFoundException | InvalidPathException exception) {
throw new ParsingException(exception, "Can't find file '%s'", fileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public void run(final FullTextFingerprint algorithm, final Report report, final
sum += computeFingerprint(issue, algorithm, charset, log);
}
}
log.logSummary();
report.mergeLogMessages(log);
report.logInfo("-> created fingerprints for %d issues (skipped %d issues)", sum, report.size() - sum);
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/edu/hm/hafner/analysis/RevApiInfoExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import java.util.Objects;

import edu.umd.cs.findbugs.annotations.CheckForNull;

Expand Down Expand Up @@ -34,7 +33,7 @@ public final class RevApiInfoExtension implements Serializable {
*/
public RevApiInfoExtension(@CheckForNull final String code, final String oldFile,
final String newFile, final Map<String, String> severities) {
this.issueName = StringUtils.defaultString(code, "-");
this.issueName = Objects.toString(code, "-");
this.oldFile = oldFile;
this.newFile = newFile;
this.severities.putAll(severities);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/edu/hm/hafner/analysis/parser/JavacParser.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package edu.hm.hafner.analysis.parser;

import java.util.Objects;
import java.util.Optional;
import java.util.regex.Matcher;

import org.apache.commons.lang3.RegExUtils;
import org.apache.commons.lang3.StringUtils;

import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueBuilder;
Expand Down Expand Up @@ -77,7 +77,7 @@ protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStre
// get rid of leading / from windows compiler output JENKINS-66738
return builder.setFileName(RegExUtils.replaceAll(matcher.group(2), "^/([a-zA-Z]):", "$1:"))
.setLineStart(matcher.group(7))
.setType(StringUtils.defaultString(getGoal(), DEFAULT_GOAL))
.setType(Objects.toString(getGoal(), DEFAULT_GOAL))
.setColumnStart(matcher.group(8))
.setCategory(category)
.setMessage(message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class SimulinkCheckParser extends IssueParser {
public Report parse(final ReaderFactory readerFactory) throws ParsingException {
try (IssueBuilder issueBuilder = new IssueBuilder();
Reader reader = readerFactory.create();
InputStream targetStream = new ReaderInputStream(reader, readerFactory.getCharset())) {
InputStream targetStream = ReaderInputStream.builder().setReader(reader).setCharset(readerFactory.getCharset()).get()) {
Document document = Jsoup.parse(targetStream, readerFactory.getCharset().name(), EMPTY_BASE_URI);

Elements systemElements = document.select(REPORT_CONTENT);
Expand Down

0 comments on commit 5f6136f

Please sign in to comment.