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

Closing ObjectOutputStream before calling toByteArray on the underlying ByteArrayOutputStream #339

Merged
merged 1 commit into from
Jan 1, 2016
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
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestDateMidnight_Basics.java
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/joda/time/TestDateTimeComparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ public void testSerialization1() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(c);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand All @@ -289,8 +289,8 @@ public void testSerialization2() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(c);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestDateTimeFieldType.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ private DateTimeFieldType doSerialization(DateTimeFieldType type) throws Excepti
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(type);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/joda/time/TestDateTimeZone.java
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,8 @@ public void testSerialization1() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(zone);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand All @@ -1043,8 +1043,8 @@ public void testSerialization2() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(zone);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestDateTime_Basics.java
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestDays.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestDurationFieldType.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ private DurationFieldType doSerialization(DurationFieldType type) throws Excepti
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(type);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestDuration_Basics.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestHours.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestInstant_Basics.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestInterval_Basics.java
Original file line number Diff line number Diff line change
Expand Up @@ -1032,8 +1032,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestLocalDateTime_Basics.java
Original file line number Diff line number Diff line change
Expand Up @@ -1051,8 +1051,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestLocalDate_Basics.java
Original file line number Diff line number Diff line change
Expand Up @@ -1106,8 +1106,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestLocalTime_Basics.java
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestMinutes.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestMonthDay_Basics.java
Original file line number Diff line number Diff line change
Expand Up @@ -769,8 +769,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestMonths.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestMutablePeriod_Basics.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestPartial_Basics.java
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/joda/time/TestPeriodType.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ private void assertEqualsAfterSerialization(PeriodType type) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(type);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand All @@ -125,8 +125,8 @@ private void assertSameAfterSerialization(PeriodType type) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(type);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestPeriod_Basics.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestSeconds.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestTimeOfDay_Basics.java
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestWeeks.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestYearMonthDay_Basics.java
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestYearMonth_Basics.java
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/TestYears.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/joda/time/tz/TestCachedDateTimeZone.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public void testSerialization() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(test);
byte[] bytes = baos.toByteArray();
oos.close();
byte[] bytes = baos.toByteArray();

ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Expand Down