-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure that failed place startups don't block server startup unless the server is configured to do so #622
Ensure that failed place startups don't block server startup unless the server is configured to do so #622
Conversation
4e5d481
to
c13889b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend creating a unit-test. Here is a test that will cause the current code in the baseline to throw an NPE. Feel free to incorporate and change to your liking.
@Test
void testInvisPlaceStartWithNullLocalPlace() throws IOException {
// setup node, startup, and DirectoryPlace
EmissaryNode node = new EmissaryNode();
Startup startup = new Startup(node.getNodeConfigurator(), node);
try (MockedStatic<DirectoryPlace> dirPlace = Mockito.mockStatic(DirectoryPlace.class)) {
DirectoryEntry entry = mock(DirectoryEntry.class);
when(entry.getLocalPlace()).thenReturn(null);
List<DirectoryEntry> dirEntries = new ArrayList<>();
dirEntries.add(0, entry);
IDirectoryPlace directoryPlace = mock(IDirectoryPlace.class);
when(directoryPlace.getEntries()).thenReturn(dirEntries);
dirPlace.when(DirectoryPlace::lookup).thenReturn(directoryPlace);
assertTrue(startup.verifyNoInvisiblePlacesStarted());
}
```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, if you add the possible unit test I'll review again.
Unit test added - thanks, @fbruton! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀🚀🚀
Mitigates potential NPEs introduced by #598. These NPEs can prevent server startup.