Browse Source

xml nameserver check

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@359325 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 19 years ago
parent
commit
75b9942dba
1 changed files with 50 additions and 2 deletions
  1. +50
    -2
      src/main/org/apache/tools/ant/Diagnostics.java

+ 50
- 2
src/main/org/apache/tools/ant/Diagnostics.java View File

@@ -18,7 +18,9 @@ package org.apache.tools.ant;


import org.apache.tools.ant.util.LoaderUtils; import org.apache.tools.ant.util.LoaderUtils;
import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.JAXPUtils;
import org.apache.tools.ant.launch.Launcher; import org.apache.tools.ant.launch.Launcher;
import org.xml.sax.XMLReader;


import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParser;
@@ -92,6 +94,7 @@ public final class Diagnostics {
} }
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
// ignore // ignore
ignoreThrowable(e);
} }
} }


@@ -176,6 +179,7 @@ public final class Diagnostics {
saxParser = saxParserFactory.newSAXParser(); saxParser = saxParserFactory.newSAXParser();
} catch (Exception e) { } catch (Exception e) {
// ignore // ignore
ignoreThrowable(e);
} }
return saxParser; return saxParser;
} }
@@ -194,6 +198,37 @@ public final class Diagnostics {
return location; return location;
} }


private static String getNamespaceParserName() {
try {
XMLReader reader = JAXPUtils.getNamespaceXMLReader();
return reader.getClass().getName();
} catch (BuildException e) {
//ignore
ignoreThrowable(e);
return null;
}
}

private static String getNamespaceParserLocation() {
try {
XMLReader reader = JAXPUtils.getNamespaceXMLReader();
return getClassLocation(reader.getClass());
} catch (BuildException e) {
//ignore
ignoreThrowable(e);
return null;
}
}

/**
* ignore exceptions. This is to allow future
* implementations to log at a verbose level
* @param thrown
*/
private static void ignoreThrowable(Throwable thrown) {
}
/** /**
* get the location of a class. Stolen from axis/webapps/happyaxis.jsp * get the location of a class. Stolen from axis/webapps/happyaxis.jsp
* @param clazz * @param clazz
@@ -223,6 +258,7 @@ public final class Diagnostics {
out.println("optional tasks : " out.println("optional tasks : "
+ getImplementationVersion(optional)); + getImplementationVersion(optional));
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
ignoreThrowable(e);
out.println("optional tasks : not available"); out.println("optional tasks : not available");
} }


@@ -269,6 +305,7 @@ public final class Diagnostics {
try { try {
sysprops = System.getProperties(); sysprops = System.getProperties();
} catch (SecurityException e) { } catch (SecurityException e) {
ignoreThrowable(e);
out.println("Access to System.getProperties() blocked " out.println("Access to System.getProperties() blocked "
+ "by a security manager"); + "by a security manager");
} }
@@ -400,14 +437,24 @@ public final class Diagnostics {
private static void doReportParserInfo(PrintStream out) { private static void doReportParserInfo(PrintStream out) {
String parserName = getXmlParserName(); String parserName = getXmlParserName();
String parserLocation = getXMLParserLocation(); String parserLocation = getXMLParserLocation();
printParserInfo(out, "XML Parser", parserName, parserLocation);
printParserInfo(out, "Namespace-aware parser",
getNamespaceParserName(),
getNamespaceParserLocation());
}

private static void printParserInfo(PrintStream out,
String parserType,
String parserName,
String parserLocation) {
if (parserName == null) { if (parserName == null) {
parserName = "unknown"; parserName = "unknown";
} }
if (parserLocation == null) { if (parserLocation == null) {
parserLocation = "unknown"; parserLocation = "unknown";
} }
out.println("XML Parser : " + parserName);
out.println("XML Parser Location: " + parserLocation);
out.println(parserType +" : " + parserName);
out.println(parserType +" Location: " + parserLocation);
} }


/** /**
@@ -452,6 +499,7 @@ public final class Diagnostics {
out.println("Warning: big clock drift -maybe a network filesystem"); out.println("Warning: big clock drift -maybe a network filesystem");
} }
} catch (IOException e) { } catch (IOException e) {
ignoreThrowable(e);
out.println("Failed to create a temporary file in the temp dir " out.println("Failed to create a temporary file in the temp dir "
+ tempdir); + tempdir);
out.println("File " + tempFile + " could not be created/written to"); out.println("File " + tempFile + " could not be created/written to");


Loading…
Cancel
Save