Fix a few issues found by FindBugs
This commit is contained in:
parent
08b19f55ad
commit
e8f5451cc9
|
@ -7,7 +7,7 @@ HAPI FHIR - Java API for HL7 FHIR Clients and Servers
|
||||||
[![Coverage Status](https://coveralls.io/repos/jamesagnew/hapi-fhir/badge.svg?branch=master&service=github)](https://coveralls.io/github/jamesagnew/hapi-fhir?branch=master)
|
[![Coverage Status](https://coveralls.io/repos/jamesagnew/hapi-fhir/badge.svg?branch=master&service=github)](https://coveralls.io/github/jamesagnew/hapi-fhir?branch=master)
|
||||||
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/ca.uhn.hapi.fhir/hapi-fhir-base/badge.svg)](http://search.maven.org/#search|ga|1|ca.uhn.hapi.fhir)
|
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/ca.uhn.hapi.fhir/hapi-fhir-base/badge.svg)](http://search.maven.org/#search|ga|1|ca.uhn.hapi.fhir)
|
||||||
[![Dependency Status](https://www.versioneye.com/user/projects/55e1d0d9c6d8f2001c00043e/badge.svg?style=flat)](https://www.versioneye.com/user/projects/55e1d0d9c6d8f2001c00043e)
|
[![Dependency Status](https://www.versioneye.com/user/projects/55e1d0d9c6d8f2001c00043e/badge.svg?style=flat)](https://www.versioneye.com/user/projects/55e1d0d9c6d8f2001c00043e)
|
||||||
[![License](https://img.shields.io/badge/license-apache%202.0-ff69b4.svg)](https://github.com/jamesagnew/hapi-fhir/blob/master/LICENSE.txt)
|
[![License](https://img.shields.io/badge/license-apache%202.0-ff69b4.svg)](http://jamesagnew.github.io/hapi-fhir/license.html)
|
||||||
|
|
||||||
Complete project documentation is available here:
|
Complete project documentation is available here:
|
||||||
http://jamesagnew.github.io/hapi-fhir/
|
http://jamesagnew.github.io/hapi-fhir/
|
||||||
|
|
|
@ -152,7 +152,7 @@ public class LoggingInterceptor implements IClientInterceptor {
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
myLog.info("Client response body:\n{}", new String(bytes));
|
myLog.info("Client response body:\n{}", new String(bytes, "UTF-8"));
|
||||||
theResponse.setEntity(new MyEntityWrapper(respEntity, bytes));
|
theResponse.setEntity(new MyEntityWrapper(respEntity, bytes));
|
||||||
} else {
|
} else {
|
||||||
myLog.info("Client response body: (none)");
|
myLog.info("Client response body: (none)");
|
||||||
|
|
|
@ -50,7 +50,6 @@ import org.codehaus.stax2.XMLOutputFactory2;
|
||||||
import org.codehaus.stax2.io.EscapingWriterFactory;
|
import org.codehaus.stax2.io.EscapingWriterFactory;
|
||||||
|
|
||||||
import com.ctc.wstx.api.WstxInputProperties;
|
import com.ctc.wstx.api.WstxInputProperties;
|
||||||
import com.ctc.wstx.stax.WstxInputFactory;
|
|
||||||
import com.ctc.wstx.stax.WstxOutputFactory;
|
import com.ctc.wstx.stax.WstxOutputFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1550,6 +1549,7 @@ public class XmlUtil {
|
||||||
if (ourInputFactory == null) {
|
if (ourInputFactory == null) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Detect if we're running with the Android lib, and force repackaged Woodstox to be used
|
||||||
Class.forName("ca.uhn.fhir.repackage.javax.xml.stream.XMLInputFactory");
|
Class.forName("ca.uhn.fhir.repackage.javax.xml.stream.XMLInputFactory");
|
||||||
System.setProperty("javax.xml.stream.XMLInputFactory", "com.ctc.wstx.stax.WstxInputFactory");
|
System.setProperty("javax.xml.stream.XMLInputFactory", "com.ctc.wstx.stax.WstxInputFactory");
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
|
@ -1589,6 +1589,7 @@ public class XmlUtil {
|
||||||
if (ourOutputFactory == null) {
|
if (ourOutputFactory == null) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Detect if we're running with the Android lib, and force repackaged Woodstox to be used
|
||||||
Class.forName("ca.uhn.fhir.repackage.javax.xml.stream.XMLOutputFactory");
|
Class.forName("ca.uhn.fhir.repackage.javax.xml.stream.XMLOutputFactory");
|
||||||
System.setProperty("javax.xml.stream.XMLOutputFactory", "com.ctc.wstx.stax.WstxOutputFactory");
|
System.setProperty("javax.xml.stream.XMLOutputFactory", "com.ctc.wstx.stax.WstxOutputFactory");
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
|
@ -1708,7 +1709,7 @@ public class XmlUtil {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Writer createEscapingWriterFor(OutputStream theOut, String theEnc) throws UnsupportedEncodingException {
|
public Writer createEscapingWriterFor(OutputStream theOut, String theEnc) throws UnsupportedEncodingException {
|
||||||
return createEscapingWriterFor(new OutputStreamWriter(theOut), theEnc);
|
return createEscapingWriterFor(new OutputStreamWriter(theOut, theEnc), theEnc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -38,6 +38,7 @@ import javax.xml.validation.Schema;
|
||||||
import javax.xml.validation.SchemaFactory;
|
import javax.xml.validation.SchemaFactory;
|
||||||
import javax.xml.validation.Validator;
|
import javax.xml.validation.Validator;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.io.input.BOMInputStream;
|
import org.apache.commons.io.input.BOMInputStream;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.w3c.dom.ls.LSInput;
|
import org.w3c.dom.ls.LSInput;
|
||||||
|
@ -203,6 +204,7 @@ class SchemaBaseValidator implements IValidatorModule {
|
||||||
|
|
||||||
InputStream baseIs = FhirValidator.class.getResourceAsStream(pathToBase);
|
InputStream baseIs = FhirValidator.class.getResourceAsStream(pathToBase);
|
||||||
if (baseIs == null) {
|
if (baseIs == null) {
|
||||||
|
IOUtils.closeQuietly(baseIs.close());
|
||||||
throw new InternalErrorException("Schema file not found: " + pathToBase);
|
throw new InternalErrorException("Schema file not found: " + pathToBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import javax.xml.transform.stream.StreamSource;
|
import javax.xml.transform.stream.StreamSource;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.oclc.purl.dsdl.svrl.SchematronOutputType;
|
import org.oclc.purl.dsdl.svrl.SchematronOutputType;
|
||||||
|
|
||||||
|
@ -120,12 +121,14 @@ public class SchematronBaseValidator implements IValidatorModule {
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
String pathToBase = myCtx.getVersion().getPathToSchemaDefinitions() + '/' + theCtx.getFhirContext().getResourceDefinition(theCtx.getResource()).getBaseDefinition().getName().toLowerCase()
|
String pathToBase = myCtx.getVersion().getPathToSchemaDefinitions() + '/' + theCtx.getFhirContext().getResourceDefinition(theCtx.getResource()).getBaseDefinition().getName().toLowerCase() + ".sch";
|
||||||
+ ".sch";
|
|
||||||
InputStream baseIs = FhirValidator.class.getResourceAsStream(pathToBase);
|
InputStream baseIs = FhirValidator.class.getResourceAsStream(pathToBase);
|
||||||
if (baseIs == null) {
|
try {
|
||||||
throw new InternalErrorException("No schematron found for resource type: "
|
if (baseIs == null) {
|
||||||
+ theCtx.getFhirContext().getResourceDefinition(theCtx.getResource()).getBaseDefinition().getImplementingClass().getCanonicalName());
|
throw new InternalErrorException("No schematron found for resource type: " + theCtx.getFhirContext().getResourceDefinition(theCtx.getResource()).getBaseDefinition().getImplementingClass().getCanonicalName());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
IOUtils.closeQuietly(baseIs);
|
||||||
}
|
}
|
||||||
|
|
||||||
retVal = SchematronResourceSCH.fromClassPath(pathToBase);
|
retVal = SchematronResourceSCH.fromClassPath(pathToBase);
|
||||||
|
|
4
pom.xml
4
pom.xml
|
@ -783,9 +783,11 @@
|
||||||
<copy todir="target/site/xref-base">
|
<copy todir="target/site/xref-base">
|
||||||
<fileset dir="hapi-fhir-base/target/site/xref" />
|
<fileset dir="hapi-fhir-base/target/site/xref" />
|
||||||
</copy>
|
</copy>
|
||||||
|
<!--
|
||||||
<copy todir="target/site/cobertura">
|
<copy todir="target/site/cobertura">
|
||||||
<fileset dir="hapi-fhir-cobertura/target/site/cobertura" />
|
<fileset dir="hapi-fhir-cobertura/target/site/cobertura" />
|
||||||
</copy>
|
</copy>
|
||||||
|
-->
|
||||||
<copy todir="target/site">
|
<copy todir="target/site">
|
||||||
<fileset dir="hapi-fhir-base/target/site" includes="checkstyle.*" />
|
<fileset dir="hapi-fhir-base/target/site" includes="checkstyle.*" />
|
||||||
</copy>
|
</copy>
|
||||||
|
@ -1164,7 +1166,9 @@
|
||||||
<module>hapi-fhir-structures-dstu2</module>
|
<module>hapi-fhir-structures-dstu2</module>
|
||||||
<module>hapi-fhir-structures-hl7org-dstu2</module>
|
<module>hapi-fhir-structures-hl7org-dstu2</module>
|
||||||
<module>hapi-fhir-jpaserver-base</module>
|
<module>hapi-fhir-jpaserver-base</module>
|
||||||
|
<!--
|
||||||
<module>hapi-fhir-cobertura</module>
|
<module>hapi-fhir-cobertura</module>
|
||||||
|
-->
|
||||||
<module>examples</module>
|
<module>examples</module>
|
||||||
</modules>
|
</modules>
|
||||||
<reporting>
|
<reporting>
|
||||||
|
|
|
@ -137,10 +137,9 @@
|
||||||
</menu>
|
</menu>
|
||||||
|
|
||||||
|
|
||||||
<menu name="Maven Reports" inherit="bottom">
|
<menu name="Reports" inherit="bottom">
|
||||||
<item name="Project Developers" href="team-list.html" />
|
<item name="Project Developers" href="team-list.html" />
|
||||||
<item name="Cobertura (Test Coverage)" href="cobertura/index.html" />
|
<item name="Coveralls (Test Coverage)" href="https://coveralls.io/github/jamesagnew/hapi-fhir" />
|
||||||
<item name="Surefire (Test Status)" href="surefire-report.html" />
|
|
||||||
<item name="FindBugs" href="findbugs.html" />
|
<item name="FindBugs" href="findbugs.html" />
|
||||||
<item name="Checkstyle" href="checkstyle.html" />
|
<item name="Checkstyle" href="checkstyle.html" />
|
||||||
</menu>
|
</menu>
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
<a href="https://maven-badges.herokuapp.com/maven-central/ca.uhn.hapi.fhir/hapi-fhir-base/badge.svg"><img src="https://maven-badges.herokuapp.com/maven-central/ca.uhn.hapi.fhir/hapi-fhir-base/badge.svg" alt="Maven Central"/></a>
|
<a href="https://maven-badges.herokuapp.com/maven-central/ca.uhn.hapi.fhir/hapi-fhir-base/badge.svg"><img src="https://maven-badges.herokuapp.com/maven-central/ca.uhn.hapi.fhir/hapi-fhir-base/badge.svg" alt="Maven Central"/></a>
|
||||||
<br/>
|
<br/>
|
||||||
<a href="https://www.versioneye.com/user/projects/55e1d0d9c6d8f2001c00043e"><img src="https://www.versioneye.com/user/projects/55e1d0d9c6d8f2001c00043e/badge.svg?style=flat" alt="VersionEye"/></a>
|
<a href="https://www.versioneye.com/user/projects/55e1d0d9c6d8f2001c00043e"><img src="https://www.versioneye.com/user/projects/55e1d0d9c6d8f2001c00043e/badge.svg?style=flat" alt="VersionEye"/></a>
|
||||||
|
<br/>
|
||||||
|
<a href="http://jamesagnew.github.io/hapi-fhir/license.html"><img src="https://img.shields.io/badge/license-apache%202.0-ff69b4.svg" alt="Apache 2.0 Licensed"/></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
Loading…
Reference in New Issue