35
35
import java .io .FileReader ;
36
36
import java .io .IOException ;
37
37
import java .io .Reader ;
38
+ import java .io .UncheckedIOException ;
38
39
import java .util .Iterator ;
39
40
import java .util .Map ;
40
41
@@ -98,23 +99,22 @@ private String getExtensionId(File root) {
98
99
File manifestJson = new File (root , "manifest.json" );
99
100
File installRdf = new File (root , "install.rdf" );
100
101
101
- if (installRdf .exists ())
102
+ if (installRdf .exists ()) {
102
103
return readIdFromInstallRdf (root );
103
- else if (manifestJson .exists ())
104
+ } else if (manifestJson .exists ()) {
104
105
return readIdFromManifestJson (root );
105
- else
106
+ } else {
106
107
throw new WebDriverException (
107
- "Extension should contain either install.rdf or manifest.json metadata file" );
108
-
108
+ "Extension should contain either install.rdf or manifest.json metadata file" );
109
+ }
109
110
}
110
111
111
112
private String readIdFromManifestJson (File root ) {
112
113
final String MANIFEST_JSON_FILE = "manifest.json" ;
113
114
File manifestJsonFile = new File (root , MANIFEST_JSON_FILE );
114
- try {
115
+ try (Reader reader = new FileReader (manifestJsonFile );
116
+ JsonInput json = new Json ().newInput (reader )) {
115
117
String addOnId = null ;
116
- Reader reader = new FileReader (manifestJsonFile );
117
- JsonInput json = new Json ().newInput (reader );
118
118
119
119
Map <String , Object > manifestObject = json .read (MAP_TYPE );
120
120
if (manifestObject .get ("applications" ) instanceof Map ) {
@@ -135,6 +135,8 @@ private String readIdFromManifestJson(File root) {
135
135
return addOnId ;
136
136
} catch (FileNotFoundException e1 ) {
137
137
throw new WebDriverException ("Unable to file manifest.json in xpi file" );
138
+ } catch (IOException e ) {
139
+ throw new UncheckedIOException (e );
138
140
}
139
141
}
140
142
0 commit comments