Skip to content

Commit

Permalink
fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Apr 20, 2024
1 parent 71a3142 commit 47713ff
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
1 change: 0 additions & 1 deletion src/test/java/org/htmlunit/cyberneko/HTMLScannerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
Expand Down
47 changes: 25 additions & 22 deletions src/test/java/org/htmlunit/cyberneko/util/FastHashMapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,19 +292,21 @@ public void serializable() throws IOException, ClassNotFoundException {
final FastHashMap<String, Integer> src = new FastHashMap<>();

final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
final ObjectOutputStream objectOutputStream = new ObjectOutputStream(buffer);
objectOutputStream.writeObject(src);
objectOutputStream.close();
try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(buffer)) {
objectOutputStream.writeObject(src);
objectOutputStream.close();
}

try (ObjectInputStream objectInputStream = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()))) {
final FastHashMap<String, Integer> copy = (FastHashMap<String, Integer>) objectInputStream.readObject();

final ObjectInputStream objectInputStream = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
final FastHashMap<String, Integer> copy = (FastHashMap<String, Integer>) objectInputStream.readObject();
objectInputStream.close();
assertEquals(src.size(), copy.size());

assertEquals(src.size(), copy.size());
// clone still works
copy.put("test", 1);
assertEquals(1, copy.get("test"));
}

// clone still works
copy.put("test", 1);
assertEquals(1, copy.get("test"));
}

/**
Expand All @@ -324,18 +326,19 @@ public void serializable_notEmpty() throws IOException, ClassNotFoundException {
src.remove("b");

final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
final ObjectOutputStream objectOutputStream = new ObjectOutputStream(buffer);
objectOutputStream.writeObject(src);
objectOutputStream.close();

final ObjectInputStream objectInputStream = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
final FastHashMap<String, Integer> copy = (FastHashMap<String, Integer>) objectInputStream.readObject();
objectInputStream.close();

assertEquals(src.size(), copy.size());
assertEquals(1, copy.get("a"));
assertEquals(3, copy.get("c"));
assertEquals(4, copy.get("d"));
try (ObjectOutputStream objectOutputStream = new ObjectOutputStream(buffer)) {
objectOutputStream.writeObject(src);
objectOutputStream.close();
}
try (ObjectInputStream objectInputStream = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()))) {
final FastHashMap<String, Integer> copy = (FastHashMap<String, Integer>) objectInputStream.readObject();
objectInputStream.close();

assertEquals(src.size(), copy.size());
assertEquals(1, copy.get("a"));
assertEquals(3, copy.get("c"));
assertEquals(4, copy.get("d"));
}
}

/**
Expand Down

0 comments on commit 47713ff

Please sign in to comment.