@@ -277,7 +277,7 @@ private static void writeLockFile(
277277 new GsonBuilder ().setPrettyPrinting ().serializeNulls ().create ().toJson (toReturn ) + "\n " ;
278278
279279 try (OutputStream os = output == null ? System .out : Files .newOutputStream (output );
280- BufferedOutputStream bos = new BufferedOutputStream (os )) {
280+ BufferedOutputStream bos = new BufferedOutputStream (os )) {
281281 bos .write (converted .getBytes (UTF_8 ));
282282 }
283283 }
@@ -287,9 +287,9 @@ private static void writeLockFile(
287287 private static Map <String , Integer > calculateArtifactHash (Map <String , Object > rendered ) {
288288 Map <String , Map <String , Object >> allInfos = new LinkedHashMap <>();
289289
290- Map <String , Object > artifacts = ( Map <String , Object >) rendered .get ("artifacts" );
291- for (Map .Entry <String , Object > dep : artifacts .entrySet ()) {
292- Map <String , Object > depInfo = ( Map < String , Object >) dep .getValue ();
290+ Map <String , Map < String , Object >> artifacts = sortMapRecursively (( Map <?, ? >) rendered .get ("artifacts" ) );
291+ for (Map .Entry <String , Map < String , Object > > dep : artifacts .entrySet ()) {
292+ Map <String , Object > depInfo = dep .getValue ();
293293 Map <String , String > shasums = (Map <String , String >) depInfo .get ("shasums" );
294294
295295 Map <String , Object > commonInfo = new LinkedHashMap <>(depInfo );
@@ -302,7 +302,7 @@ private static Map<String, Integer> calculateArtifactHash(Map<String, Object> re
302302 String sha = shaEntry .getValue ();
303303
304304 String jarSuffix = isJarType ? ":jar" : "" ;
305- String suffix = (type != "jar" ) ? jarSuffix + ":" + type : "" ;
305+ String suffix = (! type . equals ( "jar" ) ) ? jarSuffix + ":" + type : "" ;
306306
307307 Map <String , Object > typeInfo = new LinkedHashMap <>();
308308 typeInfo .put ("standard" , commonInfo );
@@ -311,15 +311,15 @@ private static Map<String, Integer> calculateArtifactHash(Map<String, Object> re
311311 }
312312 }
313313
314- Map <String , Object > repositories = ( Map <String , Object >) rendered .get ("repositories" );
315- for (Map .Entry <String , Object > repo : repositories .entrySet ()) {
316- Iterable <String > repoArtifacts = ( Iterable < String >) repo .getValue ();
314+ Map <String , Iterable < String >> repositories = sortMapRecursively (( Map <?, ? >) rendered .get ("repositories" ) );
315+ for (Map .Entry <String , Iterable < String > > repo : repositories .entrySet ()) {
316+ Iterable <String > repoArtifacts = repo .getValue ();
317317 for (String art : repoArtifacts ) {
318318 allInfos .get (art ).put ("repository" , repo .getKey ());
319319 }
320320 }
321321
322- Map <String , Set <String >> dependencies = ( Map <String , Set < String >> ) rendered .get ("dependencies" );
322+ Map <String , Set <String >> dependencies = sortMapRecursively (( Map <?, ?> ) rendered .get ("dependencies" ) );
323323 for (Map .Entry <String , Set <String >> dep : dependencies .entrySet ()) {
324324 allInfos .get (dep .getKey ()).put ("dependencies" , dep .getValue ());
325325 }
@@ -356,8 +356,8 @@ private static int calculateFinalHash(String curr, Map<String, Map<String, Objec
356356 }
357357
358358 @ SuppressWarnings ("unchecked" )
359- private static Map <String , Object > sortMapRecursively (Map <?, ?> map ) {
360- TreeMap <String , Object > sorted = new TreeMap <>();
359+ private static < T > Map <String , T > sortMapRecursively (Map <?, ?> map ) {
360+ TreeMap <String , T > sorted = new TreeMap <>();
361361 for (Map .Entry <?, ?> entry : map .entrySet ()) {
362362 Object value = entry .getValue ();
363363 if (value instanceof Map ) {
@@ -374,7 +374,7 @@ private static Map<String, Object> sortMapRecursively(Map<?, ?> map) {
374374 }
375375 value = sortedList ;
376376 }
377- sorted .put (String .valueOf (entry .getKey ()), value );
377+ sorted .put (String .valueOf (entry .getKey ()), ( T ) value );
378378 }
379379 return sorted ;
380380 }
0 commit comments