Skip to content
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

Webindex PageLoader null handling #7

Open
kennethmcfarland opened this issue Mar 7, 2019 · 0 comments
Open

Webindex PageLoader null handling #7

kennethmcfarland opened this issue Mar 7, 2019 · 0 comments

Comments

@kennethmcfarland
Copy link
Contributor

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

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;
  }
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);
	}

}
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

No branches or pull requests

1 participant