Skip to content

Commit

Permalink
Switch back to old way of creating XMLReader due to unintended side
Browse files Browse the repository at this point in the history
effects.
  • Loading branch information
Fabian Prasser committed Nov 17, 2019
1 parent 858e2dc commit c6ba0ba
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions src/gui/org/deidentifier/arx/gui/worker/WorkerLoad.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
import java.util.zip.ZipFile;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.deidentifier.arx.ARXAnonymizer;
import org.deidentifier.arx.ARXConfiguration;
Expand Down Expand Up @@ -70,6 +68,7 @@
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;

import com.univocity.parsers.csv.CsvFormat;
import com.univocity.parsers.csv.CsvParserSettings;
Expand All @@ -80,6 +79,7 @@
*
* @author Fabian Prasser
*/
@SuppressWarnings("deprecation")
public class WorkerLoad extends Worker<Model> {

/** The vocabulary to use. */
Expand Down Expand Up @@ -191,9 +191,7 @@ private void readClipboard(final Map<String, ARXNode> map,
model.getClipboard().clearClipboard();

// Parse
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
SAXParser parser = parserFactory.newSAXParser();
XMLReader xmlReader = parser.getXMLReader();
final XMLReader xmlReader = XMLReaderFactory.createXMLReader();
final InputSource inputSource = new InputSource(new BufferedInputStream(zip.getInputStream(entry)));
xmlReader.setContentHandler(new XMLHandler() {
@Override
Expand Down Expand Up @@ -262,7 +260,6 @@ private void readConfiguration(final Map<String, ARXNode> map,
* @throws SAXException
* @throws ParserConfigurationException
*/
@SuppressWarnings("deprecation")
private void readConfiguration(final String prefix,
final boolean output,
final Map<String, ARXNode> map,
Expand Down Expand Up @@ -392,9 +389,7 @@ private void readDefinition(final ModelConfiguration config,
if (entry == null) { return; }

// Read xml
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
SAXParser parser = parserFactory.newSAXParser();
XMLReader xmlReader = parser.getXMLReader();
final XMLReader xmlReader = XMLReaderFactory.createXMLReader();
final InputSource inputSource = new InputSource(new BufferedInputStream(zip.getInputStream(entry)));
xmlReader.setContentHandler(new XMLHandler() {

Expand Down Expand Up @@ -805,9 +800,7 @@ private Map<String, ARXNode> readLattice(final ZipFile zip) throws IOException,
if (entry == null) { throw new IOException(Resources.getMessage("WorkerLoad.7")); } //$NON-NLS-1$

final Map<Integer, ARXNode> map = new HashMap<Integer, ARXNode>();
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
SAXParser parser = parserFactory.newSAXParser();
XMLReader xmlReader = parser.getXMLReader();
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
InputSource inputSource = new InputSource(new BufferedInputStream(zip.getInputStream(entry)));
xmlReader.setContentHandler(new XMLHandler() {

Expand Down Expand Up @@ -891,9 +884,7 @@ protected boolean start(final String uri,

// Read the lattice for the second time
entry = zip.getEntry("lattice.xml"); //$NON-NLS-1$
parserFactory = SAXParserFactory.newInstance();
parser = parserFactory.newSAXParser();
xmlReader = parser.getXMLReader();
xmlReader = XMLReaderFactory.createXMLReader();
inputSource = new InputSource(new BufferedInputStream(zip.getInputStream(entry)));
xmlReader.setContentHandler(new XMLHandler() {

Expand Down Expand Up @@ -1020,9 +1011,7 @@ private void readMetadata(final ZipFile zip) throws IOException,
if (entry == null) { throw new IOException(Resources.getMessage("WorkerLoad.9")); } //$NON-NLS-1$

// Read vocabulary
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
SAXParser parser = parserFactory.newSAXParser();
XMLReader xmlReader = parser.getXMLReader();
final XMLReader xmlReader = XMLReaderFactory.createXMLReader();
final InputSource inputSource = new InputSource(new BufferedInputStream(zip.getInputStream(entry)));
xmlReader.setContentHandler(new XMLHandler() {

Expand Down Expand Up @@ -1089,9 +1078,7 @@ private int[] readMinMax(final ZipFile zip) throws SAXException, IOException, Pa
final int[] result = new int[]{Integer.MAX_VALUE, 0};

// Read
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
SAXParser parser = parserFactory.newSAXParser();
XMLReader xmlReader = parser.getXMLReader();
final XMLReader xmlReader = XMLReaderFactory.createXMLReader();
InputSource inputSource = new InputSource(new BufferedInputStream(zip.getInputStream(entry)));
xmlReader.setContentHandler(new XMLHandler() {

Expand Down

0 comments on commit c6ba0ba

Please sign in to comment.