aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/xml
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-08-15 13:34:55 +0200
committeriNPUTmice <daniel@gultsch.de>2014-08-15 13:34:55 +0200
commitf7c747ef4b496df77388872c750bf95100991c76 (patch)
treec566a4dc6e4f28ecd2324116c81a2418b2e666de /src/eu/siacs/conversations/xml
parent9c18d57e07dd7c2e45482f5b03534dc1d3999456 (diff)
better handling of null streams
Diffstat (limited to 'src/eu/siacs/conversations/xml')
-rw-r--r--src/eu/siacs/conversations/xml/TagWriter.java10
-rw-r--r--src/eu/siacs/conversations/xml/XmlReader.java19
2 files changed, 22 insertions, 7 deletions
diff --git a/src/eu/siacs/conversations/xml/TagWriter.java b/src/eu/siacs/conversations/xml/TagWriter.java
index 23a260f28..4828d5d93 100644
--- a/src/eu/siacs/conversations/xml/TagWriter.java
+++ b/src/eu/siacs/conversations/xml/TagWriter.java
@@ -41,12 +41,18 @@ public class TagWriter {
public TagWriter() {
}
- public void setOutputStream(OutputStream out) {
+ public void setOutputStream(OutputStream out) throws IOException {
+ if (out==null) {
+ throw new IOException();
+ }
this.plainOutputStream = out;
this.outputStream = new OutputStreamWriter(out);
}
- public OutputStream getOutputStream() {
+ public OutputStream getOutputStream() throws IOException {
+ if (this.plainOutputStream==null) {
+ throw new IOException();
+ }
return this.plainOutputStream;
}
diff --git a/src/eu/siacs/conversations/xml/XmlReader.java b/src/eu/siacs/conversations/xml/XmlReader.java
index 25d3fe38d..1c7e94e66 100644
--- a/src/eu/siacs/conversations/xml/XmlReader.java
+++ b/src/eu/siacs/conversations/xml/XmlReader.java
@@ -28,24 +28,33 @@ public class XmlReader {
this.wakeLock = wakeLock;
}
- public void setInputStream(InputStream inputStream) {
+ public void setInputStream(InputStream inputStream) throws IOException {
+ if (inputStream==null) {
+ throw new IOException();
+ }
this.is = inputStream;
try {
parser.setInput(new InputStreamReader(this.is));
} catch (XmlPullParserException e) {
- Log.d(LOGTAG,"error setting input stream");
+ throw new IOException("error resetting parser");
}
}
- public InputStream getInputStream() {
+ public InputStream getInputStream() throws IOException {
+ if (this.is==null) {
+ throw new IOException();
+ }
return is;
}
- public void reset() {
+ public void reset() throws IOException {
+ if (this.is==null) {
+ throw new IOException();
+ }
try {
parser.setInput(new InputStreamReader(this.is));
} catch (XmlPullParserException e) {
- Log.d(LOGTAG,"error resetting input stream");
+ throw new IOException("error resetting parser");
}
}