Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does DocumentBuilder Parse work OK in Eclipse, but not IntelliJ IDEA?
    primarykey
    data
    text
    <p>I've been attempting to parse some XML via <code>DocumentBuilder.Parse</code>:</p> <pre><code> try { HttpClient httpClient = new DefaultHttpClient(); HttpContext localContext = new BasicHttpContext(); HttpPost httpPost = new HttpPost(url); HttpResponse response = httpClient.execute(httpPost, localContext); InputStream in = response.getEntity().getContent(); DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = builder.parse(in); return doc; } catch (Exception e) { e.printStackTrace(); } </code></pre> <p>This works fine in Eclipse and return the <code>Document</code>.</p> <p>However, run in IntelliJ IDEA the code hits <code>Document doc = builder.parse(in);</code> then skips directly past the entire try/catch and to a return <code>null</code> (or whatever code may be there) directly after the try/catch.</p> <p>It throws no exceptions and provides no indication as to why it may simply fail!</p> <p>Does anyone have any idea why this may happen? I'd really rather not go back to Eclipse</p> <p>EDIT - Demonstration:</p> <pre><code> try { HttpClient httpClient = new DefaultHttpClient(); HttpContext localContext = new BasicHttpContext(); HttpPost httpPost = new HttpPost(url); HttpResponse response = httpClient.execute(httpPost, localContext); InputStream in = response.getEntity().getContent(); DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = builder.parse(in); //if we step through to here, this line executes then goes directly to "x" below return doc; } catch (Exception e) { e.printStackTrace(); } return null; //x </code></pre> <p>Also tried adding the following to catch errors, none of these were hit either:</p> <pre><code> builder.setErrorHandler(new ErrorHandler() { @Override public void error(SAXParseException arg0) throws SAXException { throw arg0; } @Override public void fatalError(SAXParseException arg0) throws SAXException { throw arg0; } @Override public void warning(SAXParseException arg0) throws SAXException { throw arg0; } }); </code></pre> <p>EDIT 2: Imports</p> <pre><code>import java.io.InputStream; import java.util.ArrayList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.protocol.BasicHttpContext; import org.apache.http.protocol.HttpContext; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import com.google.android.gms.maps.model.LatLng; import android.content.Context; import android.util.Log; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload