@@ -194,6 +194,7 @@ private void validate() throws IOException {
194194 throw new IllegalArgumentException ("First match w3c capabilities is zero length" );
195195 }
196196
197+ //noinspection ResultOfMethodCallIgnored
197198 firsts .stream ()
198199 .peek (map -> {
199200 Set <String > overlap = Sets .intersection (always .keySet (), map .keySet ());
@@ -256,14 +257,12 @@ public void writeTo(Appendable appendable) throws IOException {
256257 json .name (CAPABILITIES );
257258 json .beginObject ();
258259
259- json . name ( ALWAYS_MATCH );
260- getW3C (). forEach ( json :: write );
261-
260+ // Then write everything into the w3c payload. Because of the way we do this, it's easiest
261+ // to just populate the "firstMatch" section. The spec says it's fine to omit the
262+ // "alwaysMatch" field, so we do this.
262263 json .name (FIRST_MATCH );
263264 json .beginArray ();
264- //noinspection unchecked
265- json .beginObject ();
266- json .endObject ();
265+ getW3C ().forEach (json ::write );
267266 json .endArray ();
268267
269268 json .endObject (); // Close "capabilities" object
@@ -291,7 +290,7 @@ private void writeMetaData(JsonOutput out) throws IOException {
291290
292291 default :
293292 out .name (name );
294- out .write (input .< Object > read (Object .class ));
293+ out .write (input .read (Object .class ));
295294 break ;
296295 }
297296 }
@@ -437,8 +436,7 @@ public Object setValue(Object value) {
437436 return null ;
438437 }
439438
440- Map <String , Object > toReturn = new TreeMap <>();
441- toReturn .putAll (capabilities );
439+ Map <String , Object > toReturn = new TreeMap <>(capabilities );
442440
443441 // Platform name
444442 if (capabilities .containsKey (PLATFORM ) && !capabilities .containsKey (PLATFORM_NAME )) {
0 commit comments