log.debug("Data Encoding = "+encoding);
log.debug("numReads = "+numReads);
log.debug("behavior = "+behavior);
// The call stack is helpful to identify non-performant call flows
String stack = CommonUtils.stackToString(new OMException());
log.debug("call stack:" + stack);
}
// TODO NLS
if(payload == null){
throw new OMException("ParserInputStreamDataSource's InputStream is null.");
}
if (behavior == Behavior.NOT_DESTRUCTIVE) {
if (numReads > 1) {
try {
// For NOT_DESTRUCTIVE, the
// InputStream (either the original or copied InputStream)
// is reset for reuse.
if(log.isDebugEnabled()){
log.debug("reset InputStream for reuse");
}
payload.reset();
} catch (Throwable t) {
throw new OMException(t);
}
}
} else if (behavior == Behavior.ONE_USE_UNSAFE) {
// For ONE_USE_UNSAFE,
// remember the first call
// intentionally fail on the second call
if (numReads == 1) {
firstUseStack = CommonUtils.stackToString(new OMException());
if(log.isDebugEnabled()){
log.debug("ONE_USE_UNSAFE mode stack:" + firstUseStack);
}
} else {
// TODO NLS
OMException ome =
new OMException("A second read of ParserInputStreamDataSource is not allowed."
+ "The first read was done here: " + firstUseStack);
if(log.isDebugEnabled()){
log.debug("ONE_USE_UNSAFE second use exception:" + ome);
}
throw ome;