Author: veithen
Date: Tue Sep 28 11:59:08 2010
New Revision: 1002129
URL: http://svn.apache.org/viewvc?rev=1002129&view=rev
Log:
Applied two fixes to the changes done for RAMPART-304:
* Eliminated an unnecessary conversion from character stream to byte stream.
* Made the code compatible with Java 1.5.
Modified:
axis/axis2/java/rampart/trunk/modules/rampart-trust/src/main/java/org/apache/rahas/Token.java
Modified:
axis/axis2/java/rampart/trunk/modules/rampart-trust/src/main/java/org/apache/rahas/Token.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-trust/src/main/java/org/apache/rahas/Token.java?rev=1002129&r1=1002128&r2=1002129&view=diff
==============================================================================
---
axis/axis2/java/rampart/trunk/modules/rampart-trust/src/main/java/org/apache/rahas/Token.java
(original)
+++
axis/axis2/java/rampart/trunk/modules/rampart-trust/src/main/java/org/apache/rahas/Token.java
Tue Sep 28 11:59:08 2010
@@ -37,6 +37,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+import java.io.Reader;
+import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.text.DateFormat;
import java.text.ParseException;
@@ -466,8 +468,8 @@ public class Token implements Externaliz
}
try {
- InputStream is = new
ByteArrayInputStream(stringElement.getBytes("UTF-8"));
- XMLStreamReader parser =
XMLInputFactory.newInstance().createXMLStreamReader(is);
+ Reader in = new StringReader(stringElement);
+ XMLStreamReader parser =
XMLInputFactory.newInstance().createXMLStreamReader(in);
StAXOMBuilder builder = new StAXOMBuilder(parser);
OMElement documentElement = builder.getDocumentElement();
@@ -476,12 +478,12 @@ public class Token implements Externaliz
StAXOMBuilder doomBuilder = new StAXOMBuilder(doomFactory,
llomReader);
return doomBuilder.getDocumentElement();
- } catch (UnsupportedEncodingException e) {
- log.error("Cannot convert de-serialized string to OMElement.
Incorrect encoding format", e);
- throw new IOException("Cannot convert de-serialized string to
OMElement. Incorrect encoding format", e);
} catch (XMLStreamException e) {
log.error("Cannot convert de-serialized string to OMElement. Could
not create XML stream.", e);
- throw new IOException("Cannot convert de-serialized string to
OMElement. Could not create XML stream.", e);
+ // IOException only has a constructor supporting exception
chaining starting with Java 1.6
+ IOException ex = new IOException("Cannot convert de-serialized
string to OMElement. Could not create XML stream.");
+ ex.initCause(e);
+ throw ex;
}
}
}