Skip to content

Commit 73beb94

Browse files
author
Niall Pemberton
committed
IO-192 use the new exception handling methods
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@744372 13f79535-47bb-0310-9956-ffa450edef68
1 parent 6319a20 commit 73beb94

2 files changed

Lines changed: 16 additions & 102 deletions

File tree

src/java/org/apache/commons/io/input/TaggedInputStream.java

Lines changed: 8 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -105,67 +105,15 @@ public void throwIfCauseOf(Exception exception) throws IOException {
105105
}
106106
}
107107

108+
/**
109+
* Tags any IOExceptions thrown, wrapping and re-throwing.
110+
*
111+
* @param e The IOException thrown
112+
* @throws IOException if an I/O error occurs
113+
*/
108114
@Override
109-
public int available() throws IOException {
110-
try {
111-
return super.available();
112-
} catch (IOException e) {
113-
throw new TaggedIOException(e, this);
114-
}
115-
}
116-
117-
@Override
118-
public int read() throws IOException {
119-
try {
120-
return super.read();
121-
} catch (IOException e) {
122-
throw new TaggedIOException(e, this);
123-
}
124-
}
125-
126-
@Override
127-
public int read(byte[] bts, int st, int end) throws IOException {
128-
try {
129-
return super.read(bts, st, end);
130-
} catch (IOException e) {
131-
throw new TaggedIOException(e, this);
132-
}
133-
}
134-
135-
@Override
136-
public int read(byte[] bts) throws IOException {
137-
try {
138-
return super.read(bts);
139-
} catch (IOException e) {
140-
throw new TaggedIOException(e, this);
141-
}
142-
}
143-
144-
@Override
145-
public long skip(long ln) throws IOException {
146-
try {
147-
return super.skip(ln);
148-
} catch (IOException e) {
149-
throw new TaggedIOException(e, this);
150-
}
151-
}
152-
153-
@Override
154-
public void reset() throws IOException {
155-
try {
156-
super.reset();
157-
} catch (IOException e) {
158-
throw new TaggedIOException(e, this);
159-
}
160-
}
161-
162-
@Override
163-
public void close() throws IOException {
164-
try {
165-
super.close();
166-
} catch (IOException e) {
167-
throw new TaggedIOException(e, this);
168-
}
115+
protected void handleIOException(IOException e) throws IOException {
116+
throw new TaggedIOException(e, this);
169117
}
170118

171119
}

src/java/org/apache/commons/io/output/TaggedOutputStream.java

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -105,49 +105,15 @@ public void throwIfCauseOf(Exception exception) throws IOException {
105105
}
106106
}
107107

108+
/**
109+
* Tags any IOExceptions thrown, wrapping and re-throwing.
110+
*
111+
* @param e The IOException thrown
112+
* @throws IOException if an I/O error occurs
113+
*/
108114
@Override
109-
public void write(byte[] bts, int st, int end) throws IOException {
110-
try {
111-
super.write(bts, st, end);
112-
} catch (IOException e) {
113-
throw new TaggedIOException(e, this);
114-
}
115-
}
116-
117-
@Override
118-
public void write(byte[] bts) throws IOException {
119-
try {
120-
super.write(bts);
121-
} catch (IOException e) {
122-
throw new TaggedIOException(e, this);
123-
}
124-
}
125-
126-
@Override
127-
public void write(int idx) throws IOException {
128-
try {
129-
super.write(idx);
130-
} catch (IOException e) {
131-
throw new TaggedIOException(e, this);
132-
}
133-
}
134-
135-
@Override
136-
public void flush() throws IOException {
137-
try {
138-
super.flush();
139-
} catch (IOException e) {
140-
throw new TaggedIOException(e, this);
141-
}
142-
}
143-
144-
@Override
145-
public void close() throws IOException {
146-
try {
147-
super.close();
148-
} catch (IOException e) {
149-
throw new TaggedIOException(e, this);
150-
}
115+
protected void handleIOException(IOException e) throws IOException {
116+
throw new TaggedIOException(e, this);
151117
}
152118

153119
}

0 commit comments

Comments
 (0)