apache / apache/accumulo-fluo-examples
Webindex PageLoader null handling
- Dominant language
- Java
- Stars
- 2
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
webindex.data.fluo.PageLoader does not check for null inputs. When dereferencing the object to see if it is empty it doesn't first check to make sure the object exists. I wrote a simple test to show this below.
This is line 45 - 50 that shows why it happens
```java
public static PageLoader updatePage(Page page) {
Preconditions.checkArgument(!page.isEmpty(), "Page cannot be empty");
PageLoader update = new PageLoader();
update.action = Action.UPDATE;
update.page = page;
return update;
}
```
```java
package webindex.fluo;
import org.junit.Test;
import webindex.core.models.Page;
import webindex.data.fluo.PageLoader;
public class PageLoaderTest {
@Test
public void testNullPage() {
Page p = null;
PageLoader loader = PageLoader.updatePage(p);
}
@Test(expected = IllegalArgumentException.class)
public void testEmptyPageThrowsIllegalArgument() {
Page p = Page.EMPTY;
PageLoader loader = PageLoader.updatePage(p);
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.