@@ -120,9 +120,7 @@ public static XMLValidationSchemaFactory newInstance(String schemaType)
120
120
public static XMLValidationSchemaFactory newInstance (String schemaType , ClassLoader classLoader )
121
121
throws FactoryConfigurationError
122
122
{
123
- /* First, let's check and map schema type to the shorter internal
124
- * id:
125
- */
123
+ // Let's check and map schema type to the shorter internal id:
126
124
String internalId = (String ) sSchemaIds .get (schemaType );
127
125
if (internalId == null ) {
128
126
throw new FactoryConfigurationError ("Unrecognized schema type (id '" +schemaType +"')" );
@@ -131,9 +129,7 @@ public static XMLValidationSchemaFactory newInstance(String schemaType, ClassLoa
131
129
String propertyId = SYSTEM_PROPERTY_FOR_IMPL + internalId ;
132
130
SecurityException secEx = null ;
133
131
134
- /* First, let's see if there's a system property (overrides other
135
- * settings)
136
- */
132
+ // First, let's see if there's a system property (overrides other settings)
137
133
try {
138
134
String clsName = System .getProperty (propertyId );
139
135
if (clsName != null && clsName .length () > 0 ) {
@@ -156,9 +152,18 @@ public static XMLValidationSchemaFactory newInstance(String schemaType, ClassLoa
156
152
f = new File (f , "lib" );
157
153
f = new File (f , JAXP_PROP_FILENAME );
158
154
if (f .exists ()) {
155
+ Properties props = new Properties ();
159
156
try {
160
- Properties props = new Properties ();
161
- props .load (new FileInputStream (f ));
157
+ FileInputStream in = new FileInputStream (f );
158
+ // TODO: 15-Jan-2020, tatu -- when upgrading baseline to Java 7+,
159
+ // use try-with-resource instead
160
+ try {
161
+ props .load (in );
162
+ } finally {
163
+ try {
164
+ in .close ();
165
+ } catch (IOException e ) { }
166
+ }
162
167
String clsName = props .getProperty (propertyId );
163
168
if (clsName != null && clsName .length () > 0 ) {
164
169
return createNewInstance (classLoader , clsName );
0 commit comments