File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
src/main/java/com/mservicetech/openapi/validation Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 19
19
<modelVersion >4.0.0</modelVersion >
20
20
<groupId >com.mservicetech</groupId >
21
21
<artifactId >openapi-schema-validation</artifactId >
22
- <version >2.0.6 </version >
22
+ <version >2.0.7 </version >
23
23
<packaging >jar</packaging >
24
24
<description >openapi schema for openpai 3.*</description >
25
25
<url >https://github.com/mservicetech/openapi-schema-validation</url >
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ public OpenApiValidator() {
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 ();
66
67
} catch (Exception e ) {
67
68
logger .error ("initial failed:" + e );
68
69
}
@@ -74,10 +75,14 @@ public OpenApiValidator() {
74
75
* @param openapiPath The schema file name and path to use when validating request bodies
75
76
*/
76
77
public OpenApiValidator (String openapiPath ) {
77
- InputStream in = this .getClass ().getClassLoader ().getResourceAsStream (openapiPath );
78
- spec = new BufferedReader (new InputStreamReader (in , StandardCharsets .UTF_8 )).lines ().collect (Collectors .joining ("\n " ));
79
- openApiHelper = new OpenApiHelper (spec );
80
- schemaValidator = new SchemaValidator (openApiHelper .openApi3 );
78
+ try (InputStream in = this .getClass ().getClassLoader ().getResourceAsStream (openapiPath );
79
+ BufferedReader reader = new BufferedReader (new InputStreamReader (in , StandardCharsets .UTF_8 ))) {
80
+ spec = reader .lines ().collect (Collectors .joining ("\n " ));
81
+ openApiHelper = new OpenApiHelper (spec );
82
+ schemaValidator = new SchemaValidator (openApiHelper .openApi3 );
83
+ } catch (IOException e ) {
84
+ logger .error ("initial failed:" + e );
85
+ }
81
86
}
82
87
83
88
/**
You can’t perform that action at this time.
0 commit comments