Skip to content

Commit

Permalink
Merge pull request JodaOrg#339 from emopers/baos_36
Browse files Browse the repository at this point in the history
Closing ObjectOutputStream before calling toByteArray on the underlying ByteArrayOutputStream
  • Loading branch information
jodastephen committed Jan 1, 2016
2 parents e0d6015 + 0e82517 commit f415294
Show file tree
Hide file tree
Showing 33 changed files with 36 additions and 36 deletions.
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

0 comments on commit f415294

Please sign in to comment.