Skip to content

#4414 implement Set#2

Open
rogin wants to merge 2 commits intodevelopmentfrom
4414-implement-set
Open

#4414 implement Set#2
rogin wants to merge 2 commits intodevelopmentfrom
4414-implement-set

Conversation

@rogin
Copy link
Copy Markdown
Owner

@rogin rogin commented Aug 8, 2023

I have TODOs in the tests which welcome feedback involving what should happen when nulls are passed to various functions.


private Map<String, Integer> destinationIdMap;
private Map<String, Integer> destinationIdMap = Collections.emptyMap();
private Set<Integer> metaDataIds;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also default to Collections.emptySet() ?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, as we use its add() which emptySet() doesn't implement

this.metaDataIds = (Set<Integer>) connectorMessage.getSourceMap().get(Constants.DESTINATION_SET_KEY);
}
} catch (Exception e) {
metaDataIds = new HashSet<>();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the catch block even necessary here?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the rare case of a ClassCastException when pulling out the SourceMap. Until they fix that, it's worth leaving.

Comment thread server/src/com/mirth/connect/server/userutil/DestinationSet.java Outdated
Comment thread server/src/com/mirth/connect/server/userutil/DestinationSet.java
assertEquals(4, ds.size());
assertTrue(ds.addAll(Arrays.asList(5, 6)));
assertEquals(6, ds.size());
//TODO is this what we want?
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. The behavior of DestiationSet is such that if any operation fails, it returns false

assertFalse(ds.containsAll(Arrays.asList("Invalid")));
assertFalse(ds.containsAll(Collections.singleton(null)));
//TODO is this what we want?
assertFalse(ds.containsAll(null));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is what you want

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants