Skip to content

Commit

Permalink
Fix ErrorProne warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Sep 12, 2024
1 parent 70e89fd commit 704f464
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import edu.hm.hafner.analysis.util.IntegerParser;
import edu.hm.hafner.util.LookaheadStream;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import static j2html.TagCreator.*;

Expand Down Expand Up @@ -156,6 +157,7 @@ private static final class FileInformation {
* @param fileName
* the filename of the recommendation.
*/
@SuppressFBWarnings("NM")
public void setFileName(final String fileName) {
this.fileName = fileName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,13 @@ private static Report createReportWith(final int number) {
* @return bytes
*/
private static byte[] toByteArray(final Report report) {
var out = new ByteArrayOutputStream();

try (ObjectOutputStream stream = new ObjectOutputStream(out)) {
try (var out = new ByteArrayOutputStream(); ObjectOutputStream stream = new ObjectOutputStream(out)) {
stream.writeObject(report);
return out.toByteArray();
}
catch (IOException exception) {
throw new IllegalStateException("Can't serialize report " + report, exception);
}

return out.toByteArray();
}

/**
Expand All @@ -88,10 +85,9 @@ private static byte[] toByteArray(final Report report) {
* @return report
*/
@SuppressFBWarnings("OBJECT_DESERIALIZATION")
@SuppressWarnings("BanSerializableRead")
private static Report toReport(final byte[] bytes) {
var in = new ByteArrayInputStream(bytes);

try (ObjectInputStream stream = new ObjectInputStream(in)) {
try (var in = new ByteArrayInputStream(bytes); ObjectInputStream stream = new ObjectInputStream(in)) {
return (Report) stream.readObject();
}
catch (IOException | ClassNotFoundException exception) {
Expand Down

0 comments on commit 704f464

Please sign in to comment.