Program: 92229
Project: 92229
Buggy source:
/** 
 * {@link #isEmpty(boolean)} implementation, potentially invoked recursively for inspectingchild metadata and optionally removing empty ones. The map given in argument is a safety guard against infinite recursivity.
 * @param properties The metadata properties.
 * @param tested An initially singleton map, to be filled with tested metadata.
 * @param prune {@code true} for removing empty properties.
 * @return {@code true} if all metadata properties are null or empty.
 */
private static boolean isEmpty(final Map<String,Object> properties,final Map<Object,Boolean> tested,final boolean prune){
  boolean isEmpty=true;
  for (  final Map.Entry<String,Object> entry : properties.entrySet()) {
    final Object value=entry.getValue();
    final Boolean isEntryEmpty=tested.put(value,Boolean.FALSE);
    if (isEntryEmpty != null) {
      if (isEntryEmpty) {
        tested.put(value,Boolean.TRUE);
      }
 else {
        isEmpty=false;
        if (!prune)         break;
      }
    }
 else {
      boolean allElementsAreEmpty=true;
      final Collection<?> values=CollectionsExt.toCollection(value);
      for (final Iterator<?> it=values.iterator(); it.hasNext(); ) {
        final Object element=it.next();
        if (!isNullOrEmpty(element)) {
          boolean isEmptyElement=false;
          if (element instanceof AbstractMetadata) {
            final AbstractMetadata md=(AbstractMetadata)element;
            if (prune)             md.prune();
            isEmptyElement=md.isEmpty();
          }
 else           if (!prune && element instanceof Emptiable) {
            isEmptyElement=((Emptiable)element).isEmpty();
          }
 else           if (!(element instanceof Enum<?>) && !(element instanceof CodeList<?>)) {
            final MetadataStandard standard=MetadataStandard.forClass(element.getClass());
            if (standard != null) {
              isEmptyElement=isEmpty(asMap(standard,element,prune),tested,prune);
              if (!isEmptyElement && element instanceof Emptiable) {
                isEmptyElement=((Emptiable)element).isEmpty();
              }
            }
 else             if (isPrimitive(entry)) {
              if (value instanceof Number) {
                isEmptyElement=Double.isNaN(((Number)value).doubleValue());
              }
 else {
                isEmptyElement=Boolean.FALSE.equals(value);
              }
            }
          }
          if (!isEmptyElement) {
            if (!prune) {
              return false;
            }
            allElementsAreEmpty=false;
            continue;
          }
        }
        if (prune && values == value) {
          it.remove();
        }
      }
      isEmpty&=allElementsAreEmpty;
      if (allElementsAreEmpty) {
        tested.put(value,Boolean.TRUE);
        if (prune)         try {
          entry.setValue(null);
        }
 catch (        UnsupportedOperationException e) {
        }
      }
    }
  }
  return isEmpty;
}

Fixed version (ground truth):
/** 
 * {@link #isEmpty(boolean)} implementation, potentially invoked recursively for inspectingchild metadata and optionally removing empty ones. The map given in argument is a safety guard against infinite recursivity.
 * @param properties The metadata properties.
 * @param tested An initially singleton map, to be filled with tested metadata.
 * @param prune {@code true} for removing empty properties.
 * @return {@code true} if all metadata properties are null or empty.
 */
private static boolean isEmpty(final Map<String,Object> properties,final Map<Object,Boolean> tested,final boolean prune){
  boolean isEmpty=true;
  for (  final Map.Entry<String,Object> entry : properties.entrySet()) {
    final Object value=entry.getValue();
    final Boolean isEntryEmpty=tested.put(value,Boolean.FALSE);
    if (isEntryEmpty != null) {
      if (isEntryEmpty) {
        tested.put(value,Boolean.TRUE);
      }
 else {
        isEmpty=false;
        if (!prune)         break;
      }
    }
 else {
      boolean allElementsAreEmpty=true;
      final Collection<?> values=CollectionsExt.toCollection(value);
      for (final Iterator<?> it=values.iterator(); it.hasNext(); ) {
        final Object element=it.next();
        if (!isNullOrEmpty(element)) {
          boolean isEmptyElement=false;
          if (element instanceof AbstractMetadata) {
            final AbstractMetadata md=(AbstractMetadata)element;
            if (prune)             md.prune();
            isEmptyElement=md.isEmpty();
          }
 else           if (!prune && element instanceof Emptiable) {
            isEmptyElement=((Emptiable)element).isEmpty();
          }
 else           if (!(element instanceof Enumerated)) {
            final MetadataStandard standard=MetadataStandard.forClass(element.getClass());
            if (standard != null) {
              isEmptyElement=isEmpty(asMap(standard,element,prune),tested,prune);
              if (!isEmptyElement && element instanceof Emptiable) {
                isEmptyElement=((Emptiable)element).isEmpty();
              }
            }
 else             if (isPrimitive(entry)) {
              if (value instanceof Number) {
                isEmptyElement=Double.isNaN(((Number)value).doubleValue());
              }
 else {
                isEmptyElement=Boolean.FALSE.equals(value);
              }
            }
          }
          if (!isEmptyElement) {
            if (!prune) {
              return false;
            }
            allElementsAreEmpty=false;
            continue;
          }
        }
        if (prune && values == value) {
          it.remove();
        }
      }
      isEmpty&=allElementsAreEmpty;
      if (allElementsAreEmpty) {
        tested.put(value,Boolean.TRUE);
        if (prune)         try {
          entry.setValue(null);
        }
 catch (        UnsupportedOperationException e) {
        }
      }
    }
  }
  return isEmpty;
}