private void closeCallback ( AddOnModel addOnModel , IzouSoundLine izouSoundLine ) { debug ( "removing soundline " + izouSoundLine + " from " + addOnModel ) ; Predicate < WeakReference < IzouSoundLineBaseClass > > removeFromList = weakReference -> weakReference . get ( ) != null && weakReference . get ( ) . equals ( izouSoundLine ) ; synchronized ( permanentUserReadWriteLock ) { if ( permanentAddOn != null && permanentAddOn . equals ( addOnModel ) && permanentLines != null ) { permanentLines . removeIf ( removeFromList ) ; if ( permanentLines . isEmpty ( ) ) { permanentLines = null ; permissionWithoutUsage ( ) ; } } } List < WeakReference < IzouSoundLineBaseClass > > weakReferences = nonPermanent . get ( addOnModel ) ; if ( weakReferences != null ) { weakReferences . removeIf ( removeFromList ) ; synchronized ( mutingLock ) { if ( mutingManager != null && mutingManager . getMuting ( ) . equals ( addOnModel ) ) { mutingManager = mutingManager . remove ( izouSoundLine ) ; } } } submit ( this :: tidy ) ; }
the close - callback or the AddonModel removes now redundant references