Remove DataAccessResourceFailureException in xml related classes

Resolves #4132
This commit is contained in:
Marvin Deng
2022-07-07 14:13:41 +08:00
committed by Fadhel Mahmoud Ben Hassine
parent a55f556893
commit adbc39a381
4 changed files with 18 additions and 20 deletions

View File

@@ -52,7 +52,6 @@ import org.springframework.batch.item.xml.stax.UnopenedElementClosingEventWriter
import org.springframework.batch.support.transaction.TransactionAwareBufferedWriter;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.io.WritableResource;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.oxm.Marshaller;
import org.springframework.oxm.XmlMappingException;
import org.springframework.util.Assert;
@@ -458,7 +457,7 @@ public class StaxEventItemWriter<T> extends AbstractItemStreamItemWriter<T>
setPosition(position);
}
catch (IOException ioe) {
throw new DataAccessResourceFailureException("Unable to write to file resource: [" + resource + "]", ioe);
throw new ItemStreamException("Unable to write to file resource: [" + resource + "]", ioe);
}
XMLOutputFactory outputFactory = createXmlOutputFactory();
@@ -506,14 +505,14 @@ public class StaxEventItemWriter<T> extends AbstractItemStreamItemWriter<T>
}
}
catch (XMLStreamException xse) {
throw new DataAccessResourceFailureException("Unable to write to file resource: [" + resource + "]", xse);
throw new ItemStreamException("Unable to write to file resource: [" + resource + "]", xse);
}
catch (UnsupportedEncodingException e) {
throw new DataAccessResourceFailureException(
throw new ItemStreamException(
"Unable to write to file resource: [" + resource + "] with encoding=[" + encoding + "]", e);
}
catch (IOException e) {
throw new DataAccessResourceFailureException("Unable to write to file resource: [" + resource + "]", e);
throw new ItemStreamException("Unable to write to file resource: [" + resource + "]", e);
}
}
@@ -673,7 +672,7 @@ public class StaxEventItemWriter<T> extends AbstractItemStreamItemWriter<T>
bufferedWriter.write("</" + nsPrefix + getRootTagName() + ">");
}
catch (IOException ioe) {
throw new DataAccessResourceFailureException("Unable to close file resource: [" + resource + "]", ioe);
throw new XMLStreamException("Unable to close file resource: [" + resource + "]", ioe);
}
}
@@ -825,7 +824,7 @@ public class StaxEventItemWriter<T> extends AbstractItemStreamItemWriter<T>
}
}
catch (Exception e) {
throw new DataAccessResourceFailureException("Unable to write to file resource: [" + resource + "]", e);
throw new ItemStreamException("Unable to write to file resource: [" + resource + "]", e);
}
return position;
@@ -842,7 +841,7 @@ public class StaxEventItemWriter<T> extends AbstractItemStreamItemWriter<T>
channel.position(newPosition);
}
catch (IOException e) {
throw new DataAccessResourceFailureException("Unable to write to file resource: [" + resource + "]", e);
throw new ItemStreamException("Unable to write to file resource: [" + resource + "]", e);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ import javax.xml.stream.events.StartDocument;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.batch.item.ItemStreamException;
/**
* Default implementation of {@link FragmentEventReader}
@@ -71,7 +71,7 @@ public class DefaultFragmentEventReader extends AbstractEventReaderWrapper imple
startDocumentEvent = (StartDocument) wrappedEventReader.peek();
}
catch (XMLStreamException e) {
throw new DataAccessResourceFailureException("Error reading start document from event reader", e);
throw new ItemStreamException("Error reading start document from event reader", e);
}
endDocumentEvent = XMLEventFactory.newInstance().createEndDocument();
@@ -91,7 +91,7 @@ public class DefaultFragmentEventReader extends AbstractEventReaderWrapper imple
}
}
catch (XMLStreamException e) {
throw new DataAccessResourceFailureException("Error reading XML stream", e);
throw new ItemStreamException("Error reading XML stream", e);
}
return false;
}
@@ -102,7 +102,7 @@ public class DefaultFragmentEventReader extends AbstractEventReaderWrapper imple
return nextEvent();
}
catch (XMLStreamException e) {
throw new DataAccessResourceFailureException("Error reading XML stream", e);
throw new ItemStreamException("Error reading XML stream", e);
}
}
@@ -185,7 +185,7 @@ public class DefaultFragmentEventReader extends AbstractEventReaderWrapper imple
}
}
catch (XMLStreamException e) {
throw new DataAccessResourceFailureException("Error reading XML stream", e);
throw new ItemStreamException("Error reading XML stream", e);
}
}
fakeDocumentEnd = false;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014 the original author or authors.
* Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@ import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.XMLEvent;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.util.StringUtils;
/**
@@ -68,7 +67,7 @@ public class UnopenedElementClosingEventWriter extends AbstractEventWriterWrappe
ioWriter.flush();
}
catch (IOException ioe) {
throw new DataAccessResourceFailureException("Unable to close tag: " + element, ioe);
throw new XMLStreamException("Unable to close tag: " + element, ioe);
}
}
else {