File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
src/main/java/com/mservicetech/openapi/validation Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -52,20 +52,28 @@ public class OpenApiValidator {
52
52
* The default construct will try to load openapi.yml file from classpath
53
53
*/
54
54
public OpenApiValidator () {
55
+ InputStream in = this .getClass ().getClassLoader ().getResourceAsStream (OPENAPI_YAML_CONFIG );;
55
56
try {
56
- InputStream in = this .getClass ().getClassLoader ().getResourceAsStream (OPENAPI_YAML_CONFIG );
57
57
if (in == null ) {
58
58
in = this .getClass ().getClassLoader ().getResourceAsStream (OPENAPI_YML_CONFIG );
59
59
if (in ==null ) {
60
- throw new IOException ("cannot load openapi spec file" );
60
+ throw new IOException ("Cannot load openapi spec file" );
61
61
}
62
62
}
63
63
spec = new BufferedReader (new InputStreamReader (in , StandardCharsets .UTF_8 )).lines ().collect (Collectors .joining ("\n " ));
64
64
openApiHelper = new OpenApiHelper (spec );
65
65
schemaValidator = new SchemaValidator (openApiHelper .openApi3 );
66
- in .close ();
67
- } catch (Exception e ) {
68
- logger .error ("initial failed:" + e );
66
+ } catch (IOException e ) {
67
+ logger .error ("Initial failed:" + e );
68
+ }
69
+ finally {
70
+ try {
71
+ if ( in !=null ) {
72
+ in .close ();
73
+ }
74
+ } catch (IOException e ) {
75
+ logger .error (" Failed to close input stream:" + e );
76
+ }
69
77
}
70
78
}
71
79
You can’t perform that action at this time.
0 commit comments