static void filterProperties(Message message, Set<String> namesToClear) {
    List<Object> retainedProperties = messagePropertiesBuffer();
    try {
      filterProperties(message, namesToClear, retainedProperties);
    } finally {
      retainedProperties.clear(); // ensure no object references are held due to any exception
    }
  }
@Test void filterProperties_message_handlesOnSetException() throws JMSException {
    Message message = mock(Message.class);
    when(message.getPropertyNames()).thenReturn(
      Collections.enumeration(Collections.singletonList("JMS_SQS_DeduplicationId")));
    when(message.getObjectProperty("JMS_SQS_DeduplicationId")).thenReturn("");
    doThrow(new IllegalArgumentException()).when(message).setObjectProperty(anyString(), eq(""));

    assertThatCode(() -> PropertyFilter.filterProperties(message,
      Collections.singleton("b3"))).doesNotThrowAnyException();
  }