Skip to content

Commit

Permalink
Fix 1 warning by lgtm.com wrt not closing resource
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 16, 2021
1 parent 39c0338 commit 34efee8
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ public static XMLValidationSchemaFactory newInstance(String schemaType)
public static XMLValidationSchemaFactory newInstance(String schemaType, ClassLoader classLoader)
throws FactoryConfigurationError
{
/* First, let's check and map schema type to the shorter internal
* id:
*/
// Let's check and map schema type to the shorter internal id:
String internalId = (String) sSchemaIds.get(schemaType);
if (internalId == null) {
throw new FactoryConfigurationError("Unrecognized schema type (id '"+schemaType+"')");
Expand All @@ -131,9 +129,7 @@ public static XMLValidationSchemaFactory newInstance(String schemaType, ClassLoa
String propertyId = SYSTEM_PROPERTY_FOR_IMPL + internalId;
SecurityException secEx = null;

/* First, let's see if there's a system property (overrides other
* settings)
*/
// First, let's see if there's a system property (overrides other settings)
try {
String clsName = System.getProperty(propertyId);
if (clsName != null && clsName.length() > 0) {
Expand All @@ -156,9 +152,18 @@ public static XMLValidationSchemaFactory newInstance(String schemaType, ClassLoa
f = new File(f, "lib");
f = new File(f, JAXP_PROP_FILENAME);
if (f.exists()) {
Properties props = new Properties();
try {
Properties props = new Properties();
props.load(new FileInputStream(f));
FileInputStream in = new FileInputStream(f);
// TODO: 15-Jan-2020, tatu -- when upgrading baseline to Java 7+,
// use try-with-resource instead
try {
props.load(in);
} finally {
try {
in.close();
} catch (IOException e) { }
}
String clsName = props.getProperty(propertyId);
if (clsName != null && clsName.length() > 0) {
return createNewInstance(classLoader, clsName);
Expand Down

0 comments on commit 34efee8

Please sign in to comment.